Skip to content

Action to remove all but the latest version of container on ghcr.io

License

Notifications You must be signed in to change notification settings

d22/cleanup-ghcr-containers-action

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

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cleanup GHCR Containers Action

This action deletes old versions of containers on Github container registry (ghcr.io). By default only the latest version.

This action works only for containers, no other package format.

Since the Github Token has no access to the container REST API, a PAT with packages read- and write-permission is needed to access the packages.

Inputs

access-token

Required Access token (PAT) with packages read- and write-permisson.

package-name

Required Name of the package to work with

versions-to-keep

How many versions should be left untouched. Default is '1', only the latest.

Example usage

Keep only the latest version:

uses: d22/[email protected]
with:
  access-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
  package-name: 'master-tool-dev'

Keep the latest and the two following versions:

uses: d22/[email protected]
with:
  access-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
  package-name: 'master-tool-dev'
  versions-to-keep: 3 

About

Action to remove all but the latest version of container on ghcr.io

Topics

Resources

License

Stars

Watchers

Forks