From 8e2808498e0adde509e295dc29edcaffd528c23c Mon Sep 17 00:00:00 2001 From: Stefan Negru Date: Mon, 24 Jul 2023 08:02:14 +0300 Subject: [PATCH] Delete old unused container images --- .github/workflows/clean-containers.yaml | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/clean-containers.yaml diff --git a/.github/workflows/clean-containers.yaml b/.github/workflows/clean-containers.yaml new file mode 100644 index 0000000..1cb57b1 --- /dev/null +++ b/.github/workflows/clean-containers.yaml @@ -0,0 +1,32 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: ghcr actions + +on: + schedule: + - cron: "21 21 * * *" + +jobs: + clean-ghcr: + name: Delete old unused container images + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: downcase REPO name + run: | + echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} + - name: Delete 'PR' containers older than a week + uses: snok/container-retention-policy@v2.1.1 + with: + image-names: ${{ env.REGISTRY }}/${{ env.REPO }} + filter-tags: sha-*,sha256:* + cut-off: A week ago UTC + account-type: org + org-name: ${{ github.repository_owner }} + keep-at-least: 1 + token: ${{ secrets.GH_REPO_TOKEN }} + timestamp-to-use: updated_at