Skip to content

Commit eac358a

Browse files
committed
GH Actions: use fully qualified base tag when updating prod image
The base tag needs to match the one used in the k8s repo exactly, so if we are using fully qualified names it needs to be fully qualified. Add an extra step to calculate the full names for each tag as an output, which can be used both as a condition in the step to update the k8s repo as well as in its inputs.
1 parent f6e39af commit eac358a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.github/workflows/build-container.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,22 @@ jobs:
7171
tags: ${{ steps.meta.outputs.tags }}
7272
labels: ${{ steps.meta.outputs.labels }}
7373
annotations: ${{ steps.meta.outputs.annotations }}
74+
- name: Find tag names
75+
id: find-tag-names
76+
run:
77+
echo "${{ steps.meta.outputs.json }}" | jq -r '.tags | reverse | map ( { (split(":").[-1]) : . }) | add | keys[] as $k | "\($k)=\(.[$k])"' >> "$GITHUB_OUTPUT"
7478
- name: Update deployed image
75-
if: contains( format(',{0},', join( fromJSON(steps.meta.outputs.json).tags, ',' ) ), ':latest,' )
79+
if: steps.find-tag-names.outputs.latest
7680
uses: benc-uk/workflow-dispatch@v1
7781
with:
7882
repo: metacpan/metacpan-k8s
7983
ref: main
8084
workflow: set-image.yml
8185
token: ${{ steps.app-token.outputs.token }}
82-
inputs: '{ "app": "web", "environment": "prod", "base-tag": "${{ github.repository }}:latest", "tag": "${{ fromJSON(steps.meta.outputs.json).tags[0] }}" }'
86+
inputs: |
87+
{
88+
"app": "web",
89+
"environment": "prod",
90+
"base-tag": "${{ steps.find-tag-names.outputs.latest }}",
91+
"tag": "${{ fromJSON(steps.meta.outputs.json).tags[0] }}"
92+
}

0 commit comments

Comments
 (0)