Skip to content

chipkent/action-cleanup-package

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

action-cleanup-package

This is a GitHub Action to delete GitHub packages. It is very useful to clean up unneeded Docker images in the GitHub Container Registry (ghcr.io) after a PR is closed.

The example below removes Docker images in ghcr.io with the specified package name and tag. Here, github-token is set to a secret, CI_ACTION_TOKEN, which is a personal access token with package deletion permissions.

# Delete Docker images after PR merge
#

name: 'Clean up Docker images from PR'

on:
  pull_request:
    types: [closed]

jobs:
  purge-image:
    name: Delete image from ghcr.io
    runs-on: ubuntu-latest
    steps:
      - uses: chipkent/action-cleanup-package@v1.0.1
        with:
          package-name: ${{ github.event.repository.name }}
          tag: pr-${{ github.event.pull_request.number }}
          github-token: ${{ secrets.CI_ACTION_TOKEN }}