Skip to content

Commit

Permalink
Update container image cleanup GitHub actions
Browse files Browse the repository at this point in the history
Switch to dataaxiom/ghcr-cleanup-action which treats multi-arch images
correctly and refactor the cleanup jobs so that we delete untagged
versions once a day from Monday to Friday and delete PR tags once the PR
is closed (merged or unmerged).
  • Loading branch information
simu committed Jul 26, 2024
1 parent 337e1b3 commit d6f343c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/gitlab-container-image-cleanup-pr-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Delete closed PR container image tag

"on":
pull_request:
types:
- closed

jobs:
cleanup-pr-tag:
uses: ubuntu-latest
steps:
- name: Set image version for PR to branch name
run: echo "VERSION=${GITHUB_HEAD_REF//\//-}" >> ${GITHUB_ENV}

- name: Delete PR container image tag
uses: dataaxiom/ghcr-cleanup-action@v1
with:
tags: ${{ env.VERSION }}
package: ${{ github.event.repository.name }}/gitlab
token: ${{ secrets.GITHUB_TOKEN }}
12 changes: 5 additions & 7 deletions .github/workflows/prune-old-container-images.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Prune old container images
name: Prune untagged container images

"on":
schedule:
Expand All @@ -10,10 +10,8 @@ jobs:
prune:
runs-on: ubuntu-latest
steps:
- uses: actions/delete-package-versions@v5
- uses: dataaxiom/ghcr-cleanup-action@v1
with:
package-name: "${{ github.repository }}-gitlab"
package-type: container
# never delete release versions or latest
ignore-versions: "^(v.*|latest)$"
min-versions-to-keep: 3
token: ${{ secrets.GITHUB_TOKEN }}
package: ${{ github.event.repository.name }}/gitlab
validate: true

0 comments on commit d6f343c

Please sign in to comment.