Skip to content

Commit f1d8192

Browse files
committed
feat(ci): skip qemu image build if version already exists in ECR
Add check to prevent rebuilding existing images in ECR repository. The workflow now verifies if an image with the current version tag exists before proceeding with the build and publish process.
1 parent da08e35 commit f1d8192

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

.github/workflows/qemu-image-build.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,33 @@ jobs:
3232
VERSIONS=$(yq '.postgres_major[1]' ansible/vars.yml | jq -R -s -c 'split("\n")[:-1]')
3333
echo "postgres_versions=$VERSIONS" >> $GITHUB_OUTPUT
3434
35-
build:
35+
check-existing-image:
3636
needs: prepare
37+
runs-on: ubuntu-latest
38+
outputs:
39+
image_exists: ${{ steps.check-image.outputs.image_exists }}
40+
steps:
41+
- name: Checkout Repo
42+
uses: supabase/postgres/.github/actions/shared-checkout@HEAD
43+
44+
- name: Check if image already exists in ECR
45+
id: check-image
46+
env:
47+
AWS_REGION: us-east-1
48+
REPOSITORY: postgres-vm-image
49+
run: |
50+
VERSION=$(yq '.postgres_release["postgres'${{ fromJson(needs.prepare.outputs.postgres_versions) }}'"]' ansible/vars.yml | tr -d '"')
51+
if aws ecr describe-images --repository-name $REPOSITORY --image-ids imageTag=$VERSION --region $AWS_REGION 2>/dev/null; then
52+
echo "::notice title=Qemu image::Image with tag $VERSION already exists. Skipping build. Please update the version in ansible/vars.yml if you want to upload a new image."
53+
echo "image_exists=true" >> $GITHUB_OUTPUT
54+
else
55+
echo "Image with tag $VERSION does not exist. Proceeding with build."
56+
echo "image_exists=false" >> $GITHUB_OUTPUT
57+
fi
58+
59+
build:
60+
needs: [prepare, check-existing-image]
61+
if: ${{ needs.check-existing-image.outputs.image_exists == 'false' }}
3762
strategy:
3863
matrix:
3964
postgres_version: ${{ fromJson(needs.prepare.outputs.postgres_versions) }}

0 commit comments

Comments
 (0)