11name : Docker
2- on : [push, release ]
2+ on : [push]
33
44env :
55 REGISTRY : ghcr.io
@@ -10,18 +10,27 @@ jobs:
1010 runs-on : ubuntu-latest
1111 steps :
1212 - name : Check out code
13- uses : actions/checkout@v2
13+ uses : actions/checkout@v3
1414 with :
1515 fetch-depth : 2
16+ - name : Get changed files
17+ id : changed-files
18+ uses : tj-actions/changed-files@v32
19+ with :
20+ files : |
21+ server/src/configs/*.json
1622 - name : Setup Node.js environment
17- uses : actions/setup-node@v2
23+ if : steps.changed-files.outputs.any_changed == 'true'
24+ uses : actions/setup-node@v3
1825 with :
1926 node-version : 16
20- cache : " yarn"
27+ cache : ' yarn'
2128 - name : Generate latest env vars
29+ if : steps.changed-files.outputs.any_changed == 'true'
2230 run : |
2331 yarn gen-env-config
2432 - name : Commit and push changes
33+ if : steps.changed-files.outputs.any_changed == 'true'
2534 uses :
devops-infra/[email protected] 2635 with :
2736 github_token : ${{ secrets.GITHUB_TOKEN }}
@@ -31,33 +40,32 @@ jobs:
3140 needs : Sync
3241 runs-on : ubuntu-latest
3342 steps :
34- - uses : actions/checkout@v2
35-
36- - name : Set .gitsha
37- if : github.event_name == 'push'
38- run : " echo ${{github.sha}} > .gitsha"
39- - name : Set .gitref
40- if : github.event_name == 'push'
41- run : " echo ${{github.ref}} > .gitref"
43+ - uses : actions/checkout@v3
4244
43- - name : Log in to the Container registry
44- uses : docker/login-action@v1
45- with :
46- registry : ${{ env.REGISTRY }}
47- username : ${{ github.actor }}
48- password : ${{ secrets.GITHUB_TOKEN }}
45+ - name : Set .gitsha
46+ if : github.event_name == 'push'
47+ run : ' echo ${{github.sha}} > .gitsha '
48+ - name : Set .gitref
49+ if : github.event_name == 'push'
50+ run : ' echo ${{github.ref}} > .gitref '
4951
50- - name : Extract metadata (tags, labels) for Docker
51- id : meta
52- uses : docker/metadata-action@v3
53- with :
54- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
52+ - name : Log in to the Container registry
53+ uses : docker/login-action@v2
54+ with :
55+ registry : ${{ env.REGISTRY }}
56+ username : ${{ github.actor }}
57+ password : ${{ secrets.GITHUB_TOKEN }}
5558
56- - name : Build and push Docker image
57- uses : docker/build-push-action@v2
58- with :
59- context : .
60- push : true
61- tags : ${{ steps.meta.outputs.tags }}
62- labels : ${{ steps.meta.outputs.labels }}
59+ - name : Extract metadata (tags, labels) for Docker
60+ id : meta
61+ uses : docker/metadata-action@v4
62+ with :
63+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
6364
65+ - name : Build and push Docker image
66+ uses : docker/build-push-action@v3
67+ with :
68+ context : .
69+ push : true
70+ tags : ${{ steps.meta.outputs.tags }}
71+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments