11name : Client CI
2-
32env :
43 IMAGE : ghcr.io/hasadna/meirim/meirim-client
5-
6- permissions :
7- contents : read
8- packages : write
9-
104on :
115 push :
126 paths :
137 - client/**
148 - .github/workflows/client.yml
15-
169jobs :
17- # test:
18- # runs-on: ubuntu-latest
19- # services:
20- # test_mysql:
21- # image: mysql:5.7
22- # env:
23- # MYSQL_ROOT_PASSWORD: password
24- # ports:
25- # - 33060:3306
26- #
27- # steps:
28- # - uses: actions/checkout@v2
29- #
30- # - name: use node v14.x
31- # uses: actions/setup-node@v1
32- # with:
33- # node-version: 14.x
34- #
35- # - name: cache node modules
36- # uses: actions/cache@v2
37- # with:
38- # path: |
39- # ~/.cache
40- # !~/.cache/exclude
41- # **/node_modules
42- # key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
43- # restore-keys: ${{ runner.OS }}-build-${{ env.cache-name }}
44- # ${{ runner.OS }}-build-
45- # ${{ runner.OS }}-
46- #
47- # - name: install server dependencies
48- # working-directory: server
49- # run: npm install
50- #
51- # - name: create database
52- # run: mysql --protocol=tcp --host=localhost --port=33060 --user=root --password=password -e "CREATE DATABASE test_meirim character set UTF8 collate utf8_bin; SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY,',''));"
53- #
54- # - name: run migrations
55- # env:
56- # NODE_CONFIG: '{"database": {"connection": {"host": "localhost", "port": "33060", "user": "root", "password": "password", "database": "test_meirim"}}}'
57- # working-directory: server
58- # run: node node_modules/knex/bin/cli.js migrate:latest
59- #
60- # - name: install client dependencies
61- # working-directory: client
62- # run: npm install
63- #
64- # - name: build frontend
65- # working-directory: client
66- # run: npm run build
67- #
68- # - name: get ethereal credentials
69- # id: get_ethereal_credentials
70- # run: |
71- # response=$(curl -XPOST -d "{\"requestor\": \"meirim-test\", \"version\": \"0.0.1\"}" -H "Content-Type: application/json" https://api.nodemailer.com/user)
72- # echo "::set-output name=user::$(echo $response | jq -r '.user')"
73- # echo "::set-output name=pass::$(echo $response | jq -r '.pass')"
74- #
75- # - name: serve
76- # env:
77- # NODE_CONFIG: '{"database": {"connection": {"host": "localhost", "port": "33060", "user": "root", "password": "password", "database": "test_meirim"}}, "email": {"templates": {"digestPlans": "d-db0b55ab042e4ba9878715acd35c1d6c"}, "options": {"host": "smtp.ethereal.email", "port": 587, "secure": false, "auth": {"user": "${{ steps.get_ethereal_credentials.outputs.user }}", "pass": "${{ steps.get_ethereal_credentials.outputs.pass }}"}}}}'
78- # working-directory: server
79- # run: |
80- # npm run serve &
81- # sleep 3
82- #
83- # - name: e2e test
84- # working-directory: client
85- # run: |
86- # $(npm bin)/cypress run --browser chrome --headless &&
87- # $(npm bin)/cypress run --browser firefox --headless
88-
89- # build-and-deploy-staging:
90- # environment: staging
91- # runs-on: ubuntu-latest
92- # steps:
93- # - uses: actions/checkout@v2
94- #
95- # - name: use node v14.x
96- # uses: actions/setup-node@v1
97- # with:
98- # node-version: 14.x
99- #
100- # - name: install client dependencies
101- # working-directory: client
102- # run: npm install
103- #
104- # - name: create version.txt
105- # working-directory: client
106- # run: echo "https://github.com/meirim-org/meirim/commit/${{ github.sha }}" > public/version.txt
107- #
108- # - name: build
109- # working-directory: client
110- # run: npm run build
111- # env:
112- # NODE_ENV: staging
113- # BASE_NAME: ${{ github.ref_name }}
114- # PUBLIC_URL: "https://staging.meirim.org/${{ github.ref_name }}"
115- # REACT_APP_BASE_API_URL: https://staging-api.meirim.org/api
116- #
117- # - uses: jakejarvis/s3-sync-action@master
118- # with:
119- # args: --acl public-read --follow-symlinks --delete --cache-control max-age=3600
120- # env:
121- # AWS_S3_BUCKET: staging.meirim.org
122- # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CI_ACCESS_KEY }}
123- # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CI_SECRET_KEY }}
124- # SOURCE_DIR: "client/build"
125- # DEST_DIR: ${{ github.ref_name }}
126- # AWS_REGION: il-central-1
127- # - name: info
128- # run: |
129- # echo "deployed to"
130- # echo "https://staging.meirim.org/${{ github.ref_name }}"
131-
13210 build-and-deploy-prod :
133- # environment: prod
134- if : github.ref == 'refs/heads/master'
13511 runs-on : ubuntu-latest
13612 steps :
137- - uses : actions/checkout@v2
138-
139- - name : use node v14.x
140- uses : actions/setup-node@v1
13+ - uses : actions/checkout@v6
14+ - uses : actions/setup-node@v1
14115 with :
142- node-version : 14.x
143-
144- - name : install client dependencies
145- working-directory : client
16+ node-version : 18.x
17+ - working-directory : client
14618 run : npm install
147-
148- - name : create version.txt
149- working-directory : client
150- run : echo "https://github.com/meirim-org/meirim/commit/${{ github.sha }}" > public/version.txt
151-
152- - name : build
153- working-directory : client
19+ - working-directory : client
20+ run : echo "https://github.com/hasadna/meirim/commit/${{ github.sha }}" > public/version.txt
21+ - working-directory : client
15422 run : npm run build
15523 env :
15624 PUBLIC_URL : " https://meirim.org"
15725 NODE_ENV : production
15826 REACT_APP_BASE_API_URL : https://api.meirim.org/api
159-
16027 - uses : actions/upload-artifact@v4
16128 with :
16229 name : client-build
16330 path : client/build
164-
16531 - uses : docker/login-action@v3
16632 with :
16733 registry : ghcr.io
@@ -172,15 +38,16 @@ jobs:
17238 uses : docker/build-push-action@v6
17339 with :
17440 push : true
175- tags : ${{ env.IMAGE }}:${{ github.sha }}
41+ tags : |
42+ ${{ env.IMAGE }}:${{ github.sha }}
43+ ${{ github.ref == 'refs/heads/master' && format('{0}:latest', env.IMAGE) || '' }}
17644 context : client
177-
178- # - uses: jakejarvis/s3-sync-action@master
179- # with:
180- # args: --acl public-read --follow-symlinks --delete --cache-control max-age=3600
181- # env:
182- # AWS_S3_BUCKET: prod.meirim.org
183- # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CI_ACCESS_KEY }}
184- # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CI_SECRET_KEY }}
185- # SOURCE_DIR: "client/build"
186- # AWS_REGION: il-central-1
45+ cache-from : type=registry,ref=${{ env.IMAGE }}:buildcache-latest
46+ cache-to : ${{ github.ref == 'refs/heads/master' && format('type=registry,ref={0}:buildcache-latest,mode=max', env.IMAGE) || '' }}
47+ - if : github.ref == 'refs/heads/master'
48+ uses : hasadna/hasadna-k8s/.github/actions/deploy@master
49+ with :
50+ app : meirim
51+ updates : clientImage=${{ env.IMAGE }}:${{ github.sha }}
52+ env :
53+ HASADNA_K8S_DEPLOY_KEY : ${{ secrets.HASADNA_K8S_DEPLOY_KEY }}
0 commit comments