Skip to content

Latest commit

 

History

History
41 lines (32 loc) · 1.24 KB

README.md

File metadata and controls

41 lines (32 loc) · 1.24 KB

ghcr-delete-image

Delete older images from Github Container Registry by tag regex. Useful for keeping your package total size low. This action will delete all tagged packages that match the regex except the latest N packages tagged-keep-latest. This will delete the package if ANY of the tags on the image match the regex.

This action will also clean up all untagged packaged except the latest N packages untagged-keep-latest.

Usage

Example of workflow, that delete image on branch push.

name: '[RM] Preview'

on:
  push:
    branches:
      - main
jobs:
  purge-image:
    name: Delete image from ghcr.io
    runs-on: ubuntu-latest
    steps:
      - name: Delete image
	uses: r26d/[email protected]
        with:
          owner: ${{ github.repository_owner }}
          name: ghcr-delete-image-dummy
          token: ${{ secrets.GHCR_TOKEN}}
          tagged-keep-latest: 1
          untagged-keep-latest: 1
          tag-regex: testtag-.
          ignore-missing-package: true

This is based on original work from:

https://github.com/machship/ghcr-delete-image-action https://github.com/dmcconnell-m/ghcr-delete-image-action https://github.com/bots-house/ghcr-delete-image-action