Skip to content

Commit b8b7cd8

Browse files
committed
ci(gha): fix broken GH Action
* There can be only one unique ID among steps. * Merge the branch/tag logic into one step to avoid this issue. Signed-off-by: Matej Focko <[email protected]>
1 parent 2574a77 commit b8b7cd8

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

.github/workflows/build-and-push.yml

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,25 @@ jobs:
2323
- uses: actions/checkout@v3
2424

2525
- name: Extract branch name and set tag when triggered via push
26-
if: "!github.event.schedule"
2726
shell: bash
2827
run: |
2928
branch=${GITHUB_REF#refs/heads/}
30-
tag=""
31-
case $branch in
32-
main)
33-
tag="stg latest"
34-
;;
35-
stable)
36-
tag="prod"
37-
;;
38-
esac
3929
unique_tag="${branch}-${GITHUB_SHA::7}"
4030
41-
echo "branch=${branch}" >> $GITHUB_OUTPUT
42-
echo "tag=${tag} ${unique_tag}" >> $GITHUB_OUTPUT
43-
44-
id: branch_tag_push
45-
46-
- name: Extract branch name and set tags when triggered via schedule
47-
if: github.event.schedule
48-
shell: bash
49-
run: |
50-
# Do not rely on hard-coded `main`
51-
branch=${GITHUB_REF#refs/heads/}
52-
53-
# Set all tags during periodic rebuild
54-
tag="prod stg latest"
55-
unique_tag="${branch}-${GITHUB_SHA::7}"
31+
if [[ "${{ github.event_name }}" == "schedule" ]]; then
32+
tag="prod stg latest"
33+
else
34+
tag=""
35+
case $branch in
36+
main) tag="stg latest" ;;
37+
stable) tag="prod" ;;
38+
esac
39+
fi
5640
57-
# Propagate changes to outputs
5841
echo "branch=${branch}" >> $GITHUB_OUTPUT
5942
echo "tag=${tag} ${unique_tag}" >> $GITHUB_OUTPUT
6043
61-
id: branch_tag_schedule
44+
id: branch_tag
6245

6346
- name: Build Image
6447
id: build-image

0 commit comments

Comments
 (0)