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

71 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@v5
  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
    # the owner type
    # required: true
    # choices: org, user
    owner_type: ''

Scenarios

Delete all owner containers without tags

- name: Delete all owner containers without tags
  uses: Chizkiyahu/delete-untagged-ghcr-action@v5
  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@v5
    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@v5
    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: Set up Docker Buildx
  uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry with PAT_TOKEN
  uses: docker/login-action@v2
  with:
    registry: ghcr.io
    username: ${{ github.actor }}
    password: ${{ secrets.PAT_TOKEN }}
- name: Delete all containers from repository without tags
  uses: Chizkiyahu/delete-untagged-ghcr-action@v5
  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@v5
  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@v5
  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: Set up Docker Buildx
  uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry with PAT_TOKEN
  uses: docker/login-action@v2
  with:
    registry: ghcr.io
    username: ${{ github.repository_owner }}
    password: ${{ github.token }}
- name: Delete all containers from package without tags
  uses: Chizkiyahu/delete-untagged-ghcr-action@v5
  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 packages

- name: Delete all containers from package
  uses: Chizkiyahu/delete-untagged-ghcr-action@v5
  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