Skip to content

Commit

Permalink
[GitHub] update GCR cleaner tool (#8774)
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed Jun 15, 2023
1 parent b1c7ba3 commit aa23400
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions .github/workflows/clean-registry.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Remove old unused images from registry

on:
schedule:
- cron: "0 6 * * *"
workflow_dispatch: # allows for manual invocation

env:
INTERVAL_OLD_IMAGES: ${{ secrets.CLEANUP_OLD_IMAGES_TIME_DIFF }}
IMAGE: ${{ secrets.GCP_HOST_GCR }}/${{ secrets.GCP_REGISTRY_PROJECT_ID }}/${{ secrets.REGISTRY_NAME }}
IMAGE: ${{ secrets.GCP_HOST_GCR }}/${{ secrets.GCP_REGISTRY_PROJECT_ID }}/renaissance

jobs:
clean:
Expand All @@ -14,15 +16,9 @@ jobs:
with:
credentials_json: ${{ secrets.GCP_SA_KEY_GCR_PUSHER }}

- run: |
limitDate=$(date "+%Y-%m-%d %H:%M:%S" -d "$INTERVAL_OLD_IMAGES")
digests=$(gcloud container images list-tags $IMAGE \
--filter="timestamp.datetime < '$limitDate'" \
--format="get(digest)")
for digest in $digests; do
(
gcloud container images delete --quiet --force-delete-tags $IMAGE@$digest
)
done
- uses: 'docker://us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli'
with:
args: >-
-repo=${{ env.IMAGE }}
-grace=${{ secrets.INTERVAL_OLD_IMAGES }}
-keep=10

0 comments on commit aa23400

Please sign in to comment.