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 every time after building a new image and delete PR tags once
the PR is closed (merged or unmerged).
  • Loading branch information
simu committed Jul 26, 2024
1 parent 337e1b3 commit cb7bbe2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 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: 12 additions & 0 deletions .github/workflows/gitlab-container-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,15 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: 'ghcr.io/${{ env.IMAGE }}:${{ env.VERSION }}'

- name: Delete untagged container images
# We always delete all untagged container images after building an
# image. This way, there should never be stale untagged images laying
# around in the registry. In combination with the workflow that
# deletes PR tags after the PR is closed we should be able to keep the
# container image registry size in check.
uses: dataaxiom/ghcr-cleanup-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
package: ${{ github.event.repository.name }}/gitlab
validate: true
19 changes: 0 additions & 19 deletions .github/workflows/prune-old-container-images.yml

This file was deleted.

0 comments on commit cb7bbe2

Please sign in to comment.