From bac9cd3f0c1a3cf1803de53a76afd56de8b827e6 Mon Sep 17 00:00:00 2001 From: Trey Pendragon Date: Mon, 29 Jul 2024 09:50:26 -0700 Subject: [PATCH] Try automated container cleaning. Work towards #50 --- .github/workflows/clean-images.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/clean-images.yml diff --git a/.github/workflows/clean-images.yml b/.github/workflows/clean-images.yml new file mode 100644 index 00000000..df388027 --- /dev/null +++ b/.github/workflows/clean-images.yml @@ -0,0 +1,28 @@ +on: + workflow_dispatch: + schedule: + - cron: "5 * * * *" # every hour + pull_request: + branches: + - main + +jobs: + clean: + runs-on: ubuntu-latest + name: Delete old images + steps: + - name: Fetch multi-platform package version SHAs + id: multi-arch-digests + run: | + package1=$(docker manifest inspect ghcr.io/pulibrary | jq -r '.manifests.[] | .digest' | paste -s -d ' ' -) + echo "multi-arch-digests=$package1" >> $GITHUB_OUTPUT + - uses: snok/container-retention-policy@v3.0.0 + with: + account: pulibrary + token: ${{ secrets.GITHUB_TOKEN }} + image-names: "dpul-collections" + image-tags: "!main pr-* sha-*" # target any image that has a tag starting with the word test or dev + cut-off: 2w + keep-n-most-recent: 10 + skip-shas: ${{ steps.multi-arch-digests.outputs.multi-arch-digests }} + dry-run: true