@@ -2,70 +2,88 @@ name: image-build
22
33on :
44 release :
5+ # Dynamic releasetag tag is set based on the assumption this ci task only runs on release
56 types : [published]
67
7- # Jobs
88jobs :
99 # Build and push magtape-init container image
1010 build-magtape-init-image :
11- name : Push magtape-init image to DockerHub using release tag
11+ name : Build and push magtape-init images to DockerHub
1212 runs-on : ubuntu-latest
1313
1414 steps :
15-
15+
1616 - name : Check out the repo
1717 uses : actions/checkout@v2
1818
19- - name : Push release tag to Docker Hub
20- if : github.repository == 'tmobile/magtape'
21- timeout-minutes : 10
22- uses : docker/build-push-action@v1
19+ # Collect Release Tag is used to to collect information needed later in the action and expose it so it can be referenced
20+ - name : Collect Release Tag
21+ id : prep
22+ # GITHUB_REF variable must exist in action; this may rely on {{ on: release: types: [published] }} gating the action
23+ run : |
24+ echo ::set-output name=releasetag::${GITHUB_REF#refs/tags/}
25+
26+ # Part of docker/build-push-action@v2; setting up the build system
27+ - name : Set up Docker Buildx
28+ uses : docker/setup-buildx-action@v1
29+
30+ # Part of docker/build-push-action@v2; login to dockerhub
31+ - name : Login to DockerHub
32+ uses : docker/login-action@v1
2333 with :
24- username : ${{ secrets.DOCKERHUB_USERNAME }}
25- password : ${{ secrets.DOCKERHUB_PASSWORD }}
26- path : ./app/magtape-init/
27- repository : tmobile/magtape-init
28- tag_with_ref : true
34+ username : ${{ secrets.DOCKER_USERNAME }}
35+ password : ${{ secrets.DOCKER_PASSWORD }}
2936
30- - name : Push magtape-init image to DockerHub using latest tag
37+ - name : Build and push magtape-init image to DockerHub
3138 if : github.repository == 'tmobile/magtape'
3239 timeout-minutes : 10
33- uses : docker/build-push-action@v1
40+ uses : docker/build-push-action@v2
3441 with :
35- username : ${{ secrets.DOCKERHUB_USERNAME }}
36- password : ${{ secrets.DOCKERHUB_PASSWORD }}
37- path : ./app/magtape-init/
38- repository : tmobile/magtape-init
39- tags : latest
42+ context : ./app/magtape-init/
43+ # file should be specified relative to the repo root rather than relative to the context
44+ file : ./app/magtape-init/Dockerfile
45+ # push is no longer defaulted to true under v2; to push you must specify push is true
46+ push : true
47+ # Uses the releasetag output exposed by the Collect Release Tag step to set the tag under v2
48+ tags : tmobile/magtape-init:${{ steps.prep.outputs.releasetag }},tmobile/magtape-init:latest
4049
4150 # Build and push magtape container image
4251 build-magtape-image :
43- name : Push magtape image to DockerHub using release tag
52+ name : Build and push magtape images to DockerHub
4453 runs-on : ubuntu-latest
4554
4655 steps :
4756
4857 - name : Check out the repo
4958 uses : actions/checkout@v2
5059
51- - name : Push release tag to Docker Hub
52- if : github.repository == 'tmobile/magtape'
53- timeout-minutes : 10
54- uses : docker/build-push-action@v1
60+ # Collect Release Tag is used to to collect information needed later in the action and expose it so it can be referenced
61+ - name : Collect Release Tag
62+ id : prep
63+ # GITHUB_REF variable must exist in action; this may rely on {{ on: release: types: [published] }} gating the action
64+ run : |
65+ echo ::set-output name=releasetag::${GITHUB_REF#refs/tags/}
66+
67+ # Part of docker/build-push-action@v2; setting up the build system
68+ - name : Set up Docker Buildx
69+ uses : docker/setup-buildx-action@v1
70+
71+ # Part of docker/build-push-action@v2; login to dockerhub
72+ - name : Login to DockerHub
73+ uses : docker/login-action@v1
5574 with :
56- username : ${{ secrets.DOCKERHUB_USERNAME }}
57- password : ${{ secrets.DOCKERHUB_PASSWORD }}
58- path : ./app/magtape/
59- repository : tmobile/magtape
60- tag_with_ref : true
75+ username : ${{ secrets.DOCKER_USERNAME }}
76+ password : ${{ secrets.DOCKER_PASSWORD }}
6177
62- - name : Push magtape-init image to DockerHub using latest tag
78+ - name : Build and push magtape image to DockerHub
6379 if : github.repository == 'tmobile/magtape'
6480 timeout-minutes : 10
65- uses : docker/build-push-action@v1
81+ uses : docker/build-push-action@v2
6682 with :
67- username : ${{ secrets.DOCKERHUB_USERNAME }}
68- password : ${{ secrets.DOCKERHUB_PASSWORD }}
69- path : ./app/magtape/
70- repository : tmobile/magtape
71- tags : latest
83+ context : ./app/magtape/
84+ # file should be specified relative to the repo root rather than relative to the context
85+ file : ./app/magtape/Dockerfile
86+ # push is no longer defaulted to true under v2; to push you must specify push is true
87+ push : true
88+ # Uses the releasetag output exposed by the Collect Release Tag step to set the tag under v2
89+ tags : tmobile/magtape:${{ steps.prep.outputs.releasetag }},tmobile/magtape:latest
0 commit comments