Skip to content

Commit 07addf8

Browse files
committed
Rebuild weekly if needed
1 parent ac00ef4 commit 07addf8

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
- '**/README.md'
1111
workflow_dispatch:
1212

13+
schedule:
14+
# run on Saturday at 10:00 UTC
15+
- cron: '0 10 * * 6'
16+
1317
concurrency:
1418
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
1519
cancel-in-progress: true
@@ -34,10 +38,38 @@ jobs:
3438
uses: ./.github/actions/config
3539
id: set
3640

41+
check-update:
42+
name: Check for updates
43+
if: github.event_name == 'schedule'
44+
needs: set-env
45+
runs-on: ubuntu-latest
46+
outputs:
47+
res: ${{ steps.check-update.outputs.res }}
48+
steps:
49+
- name: Log in to registry
50+
shell: bash
51+
run: podman login ${{ needs.set-env.outputs.REGISTRY }} -u ${{ needs.set-env.outputs.REGISTRY_USER }} -p ${{ secrets.QUAY_PASSWORD }}
52+
53+
- name: Check update
54+
id: check-update
55+
shell: bash
56+
run: |
57+
# 'dnf check-update'
58+
# exit codes:
59+
# 0 - no updates
60+
# 100 - updates available
61+
# 125 - tag/platform not found
62+
# 127 - command not found
63+
res=0
64+
podman run --quiet --rm ${{ needs.set-env.outputs.IMAGE_REF }}:latest dnf check-update || res=$?
65+
echo "res=${res}" >> "$GITHUB_OUTPUT"
66+
echo "Exit code: '$res'"
67+
3768
build-image:
3869
name: Build image
3970
uses: AlmaLinux/atomic-ci/.github/workflows/build-image.yml@v6
40-
needs: set-env
71+
needs: [set-env, check-update]
72+
if: ${{ !failure() && !cancelled() && (github.event_name != 'schedule' || needs.check-update.outputs.res != 0) }}
4173
with:
4274
containerfile: Dockerfile
4375
image-name: "${{ needs.set-env.outputs.IMAGE_NAME }}"
@@ -63,7 +95,8 @@ jobs:
6395
test-image:
6496
name: Test image
6597
runs-on: ubuntu-latest
66-
needs: [set-env, build-image]
98+
needs: [set-env, check-update, build-image]
99+
if: ${{ !failure() && !cancelled() && (github.event_name != 'schedule' || needs.check-update.outputs.res != 0) }}
67100

68101
env:
69102
IMAGE_REF: "${{ needs.build-image.outputs.image-ref }}@${{ needs.build-image.outputs.digest }}"
@@ -89,8 +122,8 @@ jobs:
89122
90123
promote-image:
91124
name: Promote image
92-
needs: [set-env, build-image, test-image]
93-
if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
125+
needs: [set-env, check-update, build-image, test-image]
126+
if: ${{ !failure() && !cancelled() && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && (github.event_name != 'schedule' || needs.check-update.outputs.res != 0) }}
94127
uses: AlmaLinux/atomic-ci/.github/workflows/retag-image.yml@v6
95128
with:
96129
image: ${{ needs.build-image.outputs.image-ref }}@${{ needs.build-image.outputs.digest }}
@@ -108,8 +141,8 @@ jobs:
108141

109142
create-release:
110143
name: Create Release
111-
needs: [set-env, build-image, test-image, promote-image]
112-
if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
144+
needs: [set-env, check-update, build-image, test-image, promote-image]
145+
if: ${{ !failure() && !cancelled() && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && (github.event_name != 'schedule' || needs.check-update.outputs.res != 0) }}
113146
uses: AlmaLinux/atomic-ci/.github/workflows/create-release.yml@v6
114147
with:
115148
image-name: "${{ needs.set-env.outputs.IMAGE_NAME }}"

0 commit comments

Comments
 (0)