1+ ---
12# This action is centrally managed in https://github.com/<organization>/.github/
23# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
34# the above-mentioned repo.
1314 workflow_dispatch :
1415
1516jobs :
17+ check_dockerfile :
18+ name : Check Dockerfile
19+ runs-on : ubuntu-latest
20+ steps :
21+ - name : Checkout
22+ uses : actions/checkout@v3
23+
24+ - name : Check
25+ id : check
26+ run : |
27+ if [ -f "./Dockerfile" ]
28+ then
29+ FOUND=true
30+ else
31+ FOUND=false
32+ fi
33+
34+ echo "::set-output name=dockerfile::${FOUND}"
35+
36+ outputs :
37+ dockerfile : ${{ steps.check.outputs.dockerfile }}
38+
1639 check_changelog :
1740 name : Check Changelog
41+ needs : [check_dockerfile]
42+ if : ${{ needs.check_dockerfile.outputs.dockerfile == 'true' }}
1843 runs-on : ubuntu-latest
1944 steps :
20- - name : Checkout
21- if : ${{ github.ref == 'refs/heads/master' || github.base_ref == 'master' }}
22- uses : actions/checkout@v3
23-
24- - name : Verify Changelog
25- id : verify_changelog
26- if : ${{ github.ref == 'refs/heads/master' || github.base_ref == 'master' }}
27- # base_ref for pull request check, ref for push
28- uses : LizardByte/.github/actions/verify_changelog@master
29- with :
30- token : ${{ secrets.GITHUB_TOKEN }}
45+ - name : Checkout
46+ if : ${{ github.ref == 'refs/heads/master' || github.base_ref == 'master' }}
47+ uses : actions/checkout@v3
48+
49+ - name : Verify Changelog
50+ id : verify_changelog
51+ if : ${{ github.ref == 'refs/heads/master' || github.base_ref == 'master' }}
52+ # base_ref for pull request check, ref for push
53+ uses : LizardByte/.github/actions/verify_changelog@master
54+ with :
55+ token : ${{ secrets.GITHUB_TOKEN }}
3156 outputs :
3257 next_version : ${{ steps.verify_changelog.outputs.changelog_parser_version }}
3358
3459 docker :
60+ name : Docker
61+ needs : [check_dockerfile, check_changelog]
62+ if : ${{ needs.check_dockerfile.outputs.dockerfile == 'true' }}
3563 runs-on : ubuntu-latest
3664 permissions :
3765 packages : write
3866 contents : write
39- needs : [check_changelog]
4067
4168 steps :
4269 - name : Checkout
@@ -49,13 +76,13 @@ jobs:
4976 run : |
5077 # get branch name
5178 BRANCH=${GITHUB_HEAD_REF}
52-
79+
5380 if [ -z "$BRANCH" ]
5481 then
5582 echo "This is a PUSH event"
5683 BRANCH=${{ github.ref_name }}
5784 fi
58-
85+
5986 # determine to push image to dockerhub and ghcr or not
6087 if [[ $GITHUB_EVENT_NAME == "push" ]]; then
6188 PUSH=true
6794 REPOSITORY=${{ github.repository }}
6895 BASE_TAG=$(echo $REPOSITORY | tr '[:upper:]' '[:lower:]')
6996 COMMIT=${{ github.sha }}
70-
97+
7198 TAGS="${BASE_TAG}:${COMMIT:0:7},ghcr.io/${BASE_TAG}:${COMMIT:0:7}"
7299
73100 if [[ $GITHUB_REF == refs/heads/master ]]; then
82109 if [[ ${NEXT_VERSION} != "" ]]; then
83110 TAGS="${TAGS},${BASE_TAG}:${NEXT_VERSION},ghcr.io/${BASE_TAG}:${NEXT_VERSION}"
84111 fi
85-
112+
86113 # read the platforms from `.docker_platforms`
87114 PLATFORMS=$(<.docker_platforms)
88115
@@ -94,10 +121,10 @@ jobs:
94121 echo ::set-output name=tags::${TAGS}
95122
96123 - name : Set Up QEMU
97- uses : docker/setup-qemu-action@v1
124+ uses : docker/setup-qemu-action@v2
98125
99126 - name : Set up Docker Buildx
100- uses : docker/setup-buildx-action@v1
127+ uses : docker/setup-buildx-action@v2
101128 id : buildx
102129
103130 - name : Cache Docker Layers
@@ -110,21 +137,21 @@ jobs:
110137
111138 - name : Log in to Docker Hub
112139 if : ${{ steps.prepare.outputs.push == 'true' }} # PRs do not have access to secrets
113- uses : docker/login-action@v1
140+ uses : docker/login-action@v2
114141 with :
115142 username : ${{ secrets.DOCKER_HUB_USERNAME }}
116143 password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
117144
118145 - name : Log in to the Container registry
119146 if : ${{ steps.prepare.outputs.push == 'true' }} # PRs do not have access to secrets
120- uses : docker/login-action@v1
147+ uses : docker/login-action@v2
121148 with :
122149 registry : ghcr.io
123150 username : ${{ secrets.GH_BOT_NAME }}
124151 password : ${{ secrets.GH_BOT_TOKEN }}
125152
126153 - name : Build and push
127- uses : docker/build-push-action@v2
154+ uses : docker/build-push-action@v3
128155 with :
129156 context : ./
130157 file : ./Dockerfile
0 commit comments