diff --git a/.github/workflows/gitlab-container-image-cleanup-pr-tag.yml b/.github/workflows/gitlab-container-image-cleanup-pr-tag.yml new file mode 100644 index 0000000..43a6b80 --- /dev/null +++ b/.github/workflows/gitlab-container-image-cleanup-pr-tag.yml @@ -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 }} diff --git a/.github/workflows/gitlab-container-image.yml b/.github/workflows/gitlab-container-image.yml index bf8af21..887a5b8 100644 --- a/.github/workflows/gitlab-container-image.yml +++ b/.github/workflows/gitlab-container-image.yml @@ -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 diff --git a/.github/workflows/prune-old-container-images.yml b/.github/workflows/prune-old-container-images.yml deleted file mode 100644 index 641ef66..0000000 --- a/.github/workflows/prune-old-container-images.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- -name: Prune old container images - -"on": - schedule: - - cron: "17 8 * * 1-5" - workflow_dispatch: {} - -jobs: - prune: - runs-on: ubuntu-latest - steps: - - uses: actions/delete-package-versions@v5 - with: - package-name: "${{ github.repository }}-gitlab" - package-type: container - # never delete release versions or latest - ignore-versions: "^(v.*|latest)$" - min-versions-to-keep: 3