Skip to content

Commit

Permalink
fix image delete
Browse files Browse the repository at this point in the history
  • Loading branch information
AyushAgrawal-A2 committed Jan 30, 2025
1 parent 294da82 commit 5e75fb1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/preview-build-deploy-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -396,19 +396,23 @@ jobs:
for service in client api connection files multiplayer; do
REPO_NAME="quadratic-${service}"
# Get list of untagged image digests
# Get list of untagged image digests in batches
UNTAGGED_IMAGES=$(aws ecr list-images \
--repository-name "$REPO_NAME" \
--filter "tagStatus=UNTAGGED" \
--query 'imageIds[*].imageDigest' \
--output json)
# Delete untagged images if any exist
# Process images in batches of 100
if [ "$UNTAGGED_IMAGES" != "[]" ]; then
echo "Deleting untagged images from $REPO_NAME"
aws ecr batch-delete-image \
--repository-name "$REPO_NAME" \
--image-ids "$(echo $UNTAGGED_IMAGES | jq -r 'map({imageDigest: .}) | @json')"
echo "$UNTAGGED_IMAGES" | jq -c -r '. | _nwise(100) | map({imageDigest: .})' | while read -r BATCH; do
if [ ! -z "$BATCH" ]; then
aws ecr batch-delete-image \
--repository-name "$REPO_NAME" \
--image-ids "$BATCH" || true
fi
done
else
echo "No untagged images found in $REPO_NAME"
fi
Expand Down

0 comments on commit 5e75fb1

Please sign in to comment.