Skip to content

Commit

Permalink
Clean up old images after deployment.
Browse files Browse the repository at this point in the history
  • Loading branch information
ychescale9 committed Aug 14, 2024
1 parent da5fb10 commit 3c47107
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,17 @@ jobs:
--max-instances ${{ env.MAX_INSTANCES }} \
--platform managed \
--allow-unauthenticated
- name: Cleanup old images
run: |
# Get all images except the most recent 2
IMAGES_TO_DELETE=$(gcloud artifacts docker images list ${{ env.CONTAINER_IMAGE }} \
--format="get(DIGEST)" \
--sort-by="~CREATE_TIME" | tail -n +3)
# Delete the older images
for DIGEST in $IMAGES_TO_DELETE; do
gcloud artifacts docker images delete ${{ env.CONTAINER_IMAGE }}@$DIGEST \
--delete-tags \
--quiet
done

0 comments on commit 3c47107

Please sign in to comment.