Skip to content

duskmoon314/action-delete-ghcr-untagged

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

Repository files navigation

build-test

Action Delete GHCR Untagged

This action deletes all untagged versions that have exceeded the expiration date from GitHub Container Registry.

Usage

steps:
  - uses: duskmoon314/action-delete-ghcr-untagged@v1
    with:
      # Personal access token with `delete:packages` scope.
      # Required.
      token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

      # Owner type of the package. Can be `user` or `org`.
      # Default: `user`
      owner_type: user

      # Owner of the package. Can be a username or an organization name.
      # Default: `github.repository_owner`
      owner: ${{ github.repository_owner }}

      # Name of the package.
      # Required.
      package_name: my-package

      # Expiration date of the untagged versions.
      # Default: `30` (days)
      expiration: 30

You can find a real-world example in duskmoon314/LoD-frontend

Known Limitations

GitHub's API has a rate limit and I currently use a very simple Promise.all(versions.map())` to aggressively delete all untagged versions. If you have a lot of untagged versions, the action will fail with the following error:

Error: You have exceeded a secondary rate limit. Please wait a few minutes before you try again.