Skip to content

Commit 7fb5a6e

Browse files
marvinrudermartinpitt
authored andcommitted
containers/ws: Publish image more frequently, only when needed
* Change cron schedule to daily * Compare current version to tags in registry, skip push if match found * Force push image if workflow dispatched manually with input set Signed-off-by: Marvin A. Ruder <[email protected]>
1 parent b0fd511 commit 7fb5a6e

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

.github/workflows/build-ws-container.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
name: build-ws-container
22
on:
3-
# auto-refresh every Monday morning
3+
# auto-refresh every day
44
schedule:
5-
- cron: '0 2 * * 1'
5+
- cron: '0 2 * * *'
66
# can be run manually on https://github.com/cockpit-project/cockpit/actions
77
workflow_dispatch:
8+
inputs:
9+
FORCE_PUSH:
10+
description: 'Push the image even if an image with the same version already exists in the registry'
11+
type: boolean
12+
required: false
13+
default: false
814

915
env:
1016
registry_repo: ${{ vars.REGISTRY_REPO || 'quay.io/cockpit/ws' }}
@@ -24,6 +30,7 @@ jobs:
2430
timeout-minutes: 20
2531
outputs:
2632
VERSION: ${{ steps.build.outputs.VERSION }}
33+
SKIP_BUILD: ${{ steps.check_image.outputs.SKIP_BUILD }}
2734

2835
steps:
2936
- name: Clone repository
@@ -46,6 +53,17 @@ jobs:
4653
containers/ws/release.sh
4754
$RUNC save --format=oci-archive $IMAGE_TAG > cockpit-ws-${{ matrix.build.label }}.tar
4855
56+
- name: Check for existing image
57+
id: check_image
58+
run: |
59+
if skopeo inspect docker://${{ env.registry_repo }}:${{ steps.build.outputs.VERSION }}; then
60+
echo "Image with version ${{ steps.build.outputs.VERSION }} already exists, skipping push unless forced."
61+
echo "SKIP_BUILD=true" >> $GITHUB_OUTPUT
62+
else
63+
echo "Image with version ${{ steps.build.outputs.VERSION }} does not exist, proceeding to push image."
64+
echo "SKIP_BUILD=false" >> $GITHUB_OUTPUT
65+
fi
66+
4967
- name: Save image to artifacts
5068
uses: actions/upload-artifact@v4
5169
with:
@@ -55,7 +73,7 @@ jobs:
5573
manifest:
5674
needs: build
5775
environment: quay.io
58-
76+
if: ${{ needs.build.outputs.SKIP_BUILD != 'true' || inputs.FORCE_PUSH == true }}
5977
runs-on: ubuntu-latest
6078
timeout-minutes: 20
6179

0 commit comments

Comments
 (0)