Skip to content

Chizkiyahu/delete-untagged-ghcr-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

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

delete-untagged-ghcr-action

test Codacy Badge

Action for delete containers from Github container registry

delete all / untagged ghcr containers in a repository

Usage

- name: Delete untagged ghcr
  uses: Chizkiyahu/delete-untagged-ghcr-action@v6
  with:
    # Personal access token (PAT) used to fetch the repository. The PAT is configured
    # with the local git config, which enables your scripts to run authenticated git
    # commands. The post-job step removes the PAT.
    # needs delete:packages permissions
    # required: true
    # [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
    token: ${{ secrets.PAT_TOKEN }}
    # Repository name or  name with owner
    # Delete only from repository name
    # Default: ${{ github.repository }}
    repository: ''
    # 'The repository owner name'
    # Default: ${{ github.repository_owner }}
    repository_owner: ''
    # 'The package names'
    # Delete only from comma separated package names
    # required: false
    package_name: ''
    # Delete only package versions without tag
    # required: false
    # Default: true
    # choices: true, false
    untagged_only: true
    # Exclude untagged multiplatform packages from deletion
    # Manifests are usually such packages so they should be excluded
    # only for untagged_only=true
    # Default: true
    # needs docker installed
    except_untagged_multiplatform: true
    # Include signatures corresponding to deleted packages
    # without tags. Signature has the `sha256-<digest>.sig` tag where 
    # respective untagged package has `sha256:<digest>` name
    # required: false
    # default: false
    with_sigs: true
    # The owner type
    # required: true
    # choices: org, user
    owner_type: ''

Debugging

Set the environment variable ACTIONS_STEP_DEBUG to true on the step running this action to enable verbose output. The GitHub Actions UI also exposes an "Enable debug logging" option which sets this variable automatically.

Scenarios

Delete all owner containers without tags

- name: Delete all owner containers without tags
  uses: Chizkiyahu/delete-untagged-ghcr-action@v6
  with:
      token: ${{ secrets.PAT_TOKEN }}
      repository_owner: ${{ github.repository_owner }}
      owner_type: org # or user

Delete all owner containers

  - name: Delete all owner containers
    uses: Chizkiyahu/delete-untagged-ghcr-action@v6
    with:
        token: ${{ secrets.PAT_TOKEN }}
        repository_owner: ${{ github.repository_owner }}
        untagged_only: false
        owner_type: org # or user

Delete all containers from repository without tags

  - name: Delete all containers from repository without tags
    uses: Chizkiyahu/delete-untagged-ghcr-action@v6
    with:
        token: ${{ secrets.PAT_TOKEN }}
        repository_owner: ${{ github.repository_owner }}
        repository: ${{ github.repository }}
        untagged_only: true
        owner_type: org # or user

Delete all containers from repository without tags except untagged multiplatform packages

- name: Delete all containers from repository without tags
  uses: Chizkiyahu/delete-untagged-ghcr-action@v6
  with:
      token: ${{ secrets.PAT_TOKEN }}
      repository_owner: ${{ github.repository_owner }}
      repository: ${{ github.repository }}
      untagged_only: true
      owner_type: org # or user
      except_untagged_multiplatform: true

Delete all containers from repository

- name: Delete all containers from repository
  uses: Chizkiyahu/delete-untagged-ghcr-action@v6
  with:
      token: ${{ secrets.PAT_TOKEN }}
      repository_owner: ${{ github.repository_owner }}
      repository: ${{ github.repository }}
      untagged_only: false
      owner_type: org # or user

Delete all containers from package without tags

- name: Delete all containers from package without tags
  uses: Chizkiyahu/delete-untagged-ghcr-action@v6
  with:
      token: ${{ github.token }}
      repository_owner: ${{ github.repository_owner }}
      repository: ${{ github.repository }}
      package_name: the-package-name
      untagged_only: true
      owner_type: org # or user

Delete all containers from package without tags except untagged multiplatform packages

- name: Delete all containers from package without tags
  uses: Chizkiyahu/delete-untagged-ghcr-action@v6
  with:
      token: ${{ github.token }}
      repository_owner: ${{ github.repository_owner }}
      repository: ${{ github.repository }}
      package_name: the-package-name
      untagged_only: true
      owner_type: org # or user
      except_untagged_multiplatform: true

Delete all containers from package without tags and corresponding tagged signatures

Important

This option has been tested with v3.7.0 cosign-installer action using cosign-release v2.4.1. See workflow for example ("Install cosign" and "Sign the published Docker image" steps).

- name: Delete all containers from package without tags
  uses: Chizkiyahu/delete-untagged-ghcr-action@v6
  with:
      token: ${{ github.token }}
      repository_owner: ${{ github.repository_owner }}
      repository: ${{ github.repository }}
      package_name: the-package-name
      untagged_only: true
      with_sigs: true
      owner_type: org # or user

Delete all containers from packages

- name: Delete all containers from package
  uses: Chizkiyahu/delete-untagged-ghcr-action@v6
  with:
      token: ${{ github.token }}
      repository_owner: ${{ github.repository_owner }}
      repository: ${{ github.repository }}
      package_name: the-package-name, other-package-name
      untagged_only: false
      owner_type: org # or user

Debugging

Set the environment variable ACTIONS_STEP_DEBUG to true on the step running this action to enable verbose output. The GitHub Actions UI also exposes an "Enable debug logging" option which sets this variable automatically.

- name: Delete all containers from repository without tags
  uses: Chizkiyahu/delete-untagged-ghcr-action@v6
  env:
      ACTIONS_STEP_DEBUG: true
  with:
      token: ${{ secrets.PAT_TOKEN }}
      repository_owner: ${{ github.repository_owner }}
      repository: ${{ github.repository }}
      untagged_only: true
      owner_type: org # or user
      except_untagged_multiplatform: true

Packages

 
 
 

Contributors 9

Languages