1111 - " 06-demo-application/**/*"
1212
1313jobs :
14+ generate-image-tag :
15+ runs-on : ubuntu-latest
16+ outputs :
17+ image_tag : ${{ steps.generate-image-tag.outputs.image_tag }}
18+ steps :
19+ - name : Checkout
20+ uses : actions/checkout@v4
21+ with :
22+ # Necessary to get all tags for IMAGE_TAG generation with git describe
23+ fetch-depth : 0
24+
25+ - name : Install Task
26+ uses : arduino/setup-task@v2
27+ with :
28+ version : 3.x
29+
30+ - name : Generate Image Tag
31+ id : generate-image-tag
32+ working-directory : 14-cicd/github-actions
33+ run : |
34+ image_tag=$(task generate-version-tag)
35+ echo "image_tag=$image_tag" >> $GITHUB_OUTPUT
36+
1437 build-tag-push :
1538 runs-on : ubuntu-latest
39+ needs : generate-image-tag
1640 strategy :
1741 matrix :
1842 path :
2549 steps :
2650 - name : Checkout
2751 uses : actions/checkout@v4
28- with :
29- # Necessary to get all tags for IMAGE_TAG generation with git describe
30- fetch-depth : 0
3152
3253 - name : Install Task
3354 uses : arduino/setup-task@v2
@@ -65,39 +86,28 @@ jobs:
6586
6687 - name : Build Image
6788 env :
68- IMAGE_TAG : ${{ steps .generate-image-tag.outputs.image_tag }}
89+ IMAGE_TAG : ${{ needs .generate-image-tag.outputs.image_tag }}
6990 working-directory : ${{ matrix.path }}
7091 run : |
7192 task build-container-image-multi-arch IMAGE_TAG=${IMAGE_TAG}
7293
7394 update-tags :
7495 runs-on : ubuntu-latest
75- needs : build-tag-push
96+ needs : [generate-image-tag, build-tag-push]
7697
7798 steps :
7899 - name : Checkout
79100 uses : actions/checkout@v4
80- with :
81- # Necessary to get all tags for IMAGE_TAG generation with git describe
82- fetch-depth : 0
83101
84102 - name : Install Task
85103 uses : arduino/setup-task@v2
86104 with :
87105 version : 3.x
88106
89- # TODO: generate once and use everywhere (to avoid race condition)
90- - name : Generate Image Tag
91- id : generate-image-tag
92- working-directory : 14-cicd/github-actions
93- run : |
94- image_tag=$(task generate-version-tag)
95- echo "image_tag=$image_tag" >> $GITHUB_OUTPUT
96-
97107 - name : Update Image Tags
98108 working-directory : 14-cicd/github-actions
99109 env :
100- IMAGE_TAG : ${{ steps .generate-image-tag.outputs.image_tag }}
110+ IMAGE_TAG : ${{ needs .generate-image-tag.outputs.image_tag }}
101111 run : |
102112 # Update staging tags for push to main or release tag
103113 task update-staging-image-tags NEW_TAG=${IMAGE_TAG}
@@ -112,4 +122,4 @@ jobs:
112122 with :
113123 base : main
114124 token : ${{ secrets.DEVOPS_DIRECTIVE_KUBERNETES_COURSE_GITHUB_ACTION_PAT }}
115- title : " Update image tags to (${{ steps .generate-image-tag.outputs.image_tag }})"
125+ title : " Update image tags to (${{ needs .generate-image-tag.outputs.image_tag }})"
0 commit comments