@@ -2,39 +2,53 @@ name: Docker image build
22
33on :
44 push :
5- branches :
6- - master
5+ branches :
6+ - master
77 tags :
8- - release-*
8+ - release-*
99
1010jobs :
1111 build :
1212 runs-on : ubuntu-latest
1313 steps :
14- - uses : actions/checkout@v2
15- - name : Log in to Docker Hub
16- uses : docker/login-action@v1
17- with :
18- username : ${{ secrets.DOCKER_USERNAME }}
19- password : ${{ secrets.DOCKER_PASSWORD }}
20-
21- - name : Push master branch snapshot to Docker Hub
22- if : ${{ github.ref == 'refs/heads/master' }}
23- uses : docker/build-push-action@v2
24- with :
25- file : build/docker/Dockerfile
26- push : true
27- tags : robcast/digilib:snapshot
28-
29- - name : extract git tag
30- if : ${{ startsWith(github.ref, 'refs/tags/') }}
31- run : echo "GIT_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
32- - name : Push tagged release to Docker Hub
33- if : ${{ startsWith(github.ref, 'refs/tags/') }}
34- uses : docker/build-push-action@v2
35- with :
36- file : build/docker/Dockerfile
37- push : true
38- tags : |
39- robcast/digilib:${{ env.GIT_TAG }}
40- robcast/digilib:latest
14+ - uses : actions/checkout@v2
15+
16+ - name : Log in to Docker Hub
17+ uses : docker/login-action@v1
18+ with :
19+ username : ${{ secrets.DOCKER_USERNAME }}
20+ password : ${{ secrets.DOCKER_PASSWORD }}
21+ - name : Log in to the Github registry
22+ uses : docker/login-action@v1
23+ with :
24+ registry : ghcr.io
25+ username : ${{ github.actor }}
26+ password : ${{ secrets.GITHUB_TOKEN }}
27+
28+ - name : Build and push master branch snapshot
29+ if : ${{ github.ref == 'refs/heads/master' }}
30+ uses : docker/build-push-action@v2
31+ with :
32+ file : build/docker/Dockerfile
33+ push : true
34+ tags : |
35+ robcast/digilib:snapshot
36+ ghcr.io/robcast/digilib:snapshot
37+
38+ - name : Extract metadata (tags, labels) for Docker
39+ id : meta
40+ if : ${{ startsWith(github.ref, 'refs/tags/') }}
41+ uses : docker/metadata-action@v3
42+ with :
43+ images : |
44+ robcast/digilib
45+ ghcr.io/robcast/digilib
46+
47+ - name : Build and push tagged version
48+ if : ${{ startsWith(github.ref, 'refs/tags/') }}
49+ uses : docker/build-push-action@v2
50+ with :
51+ file : build/docker/Dockerfile
52+ push : true
53+ tags : ${{ steps.meta.outputs.tags }}
54+ labels : ${{ steps.meta.outputs.labels }}
0 commit comments