Skip to content

Commit 2574a77

Browse files
authored
ci(gha): enable periodic rebuild of the images (#217)
Related to #216
2 parents 37e7707 + 8e000c3 commit 2574a77

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
- main
66
- stable
77
workflow_dispatch:
8+
schedule:
9+
- cron: "0 0 10 * *"
810

911
jobs:
1012
build-n-push:
@@ -20,7 +22,8 @@ jobs:
2022
steps:
2123
- uses: actions/checkout@v3
2224

23-
- name: Extract branch name and set tag
25+
- name: Extract branch name and set tag when triggered via push
26+
if: "!github.event.schedule"
2427
shell: bash
2528
run: |
2629
branch=${GITHUB_REF#refs/heads/}
@@ -33,10 +36,29 @@ jobs:
3336
tag="prod"
3437
;;
3538
esac
39+
unique_tag="${branch}-${GITHUB_SHA::7}"
40+
3641
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"
3755
unique_tag="${branch}-${GITHUB_SHA::7}"
56+
57+
# Propagate changes to outputs
58+
echo "branch=${branch}" >> $GITHUB_OUTPUT
3859
echo "tag=${tag} ${unique_tag}" >> $GITHUB_OUTPUT
39-
id: branch_tag
60+
61+
id: branch_tag_schedule
4062

4163
- name: Build Image
4264
id: build-image

0 commit comments

Comments
 (0)