Delete image from Github Container Registry by tag. Useful for cleanup of pull request scoped images.
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:
owner: bots-house
name: some-web-service
# is_user: true # Set this if owner is a user and not an org
# NOTE: using Personal Access Token
token: ${{ secrets.PAT }}
tag: pr-${{github.event.pull_request.number}}
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:
owner: bots-house
name: some-web-service
# is_user: true # Set this if owner is a user and not an org
# NOTE: using Personal Access Token
token: ${{ secrets.PAT }}
# Keep latest N untagged images
untagged-keep-latest: 3