Skip to content
delete

GitHub Action

GHCR Delete Image

v1.1.0 Latest version

GHCR Delete Image

delete

GHCR Delete Image

Delete images from ghcr.io with different strategies.

Installation

Copy and paste the following snippet into your .yml file.

              

- name: GHCR Delete Image

uses: bots-house/[email protected]

Learn more about this action in bots-house/ghcr-delete-image-action

Choose a version

ghcr-delete-image

CI wakatime

Delete image from Github Container Registry by tag. Useful for cleanup of pull request scoped images.

Usage

Delete image when PR was closed.

name: Cleanup PR Images

on:
  pull_request:
    types: [closed]

jobs:
  purge-image:
    name: Delete image from ghcr.io
    runs-on: ubuntu-latest
    steps:
      - name: Delete image
        uses: bots-house/[email protected]
        with:
          # NOTE: at now only orgs is supported
          owner: bots-house
          name: some-web-service
          # NOTE: using Personal Access Token
          token: ${{ secrets.PAT }}
          tag: pr-${{github.event.pull_request.number}}

Keep latest N untagged images

name: Cleanup Untagged Images

on:
  # every sunday at 00:00
  schedule:
    - cron: "0 0 * * SUN"
  # or manually
  workflow_dispatch:

jobs:
  delete-untagged-images:
    name: Delete Untagged Images
    runs-on: ubuntu-latest
    steps:
      - uses: bots-house/[email protected]
        with:
          # NOTE: at now only orgs is supported
          owner: bots-house
          name: some-web-service
          # NOTE: using Personal Access Token
          token: ${{ secrets.PAT }}
          # Keep latest N untagged images
          untagged-keep-latest: 3