• Stars
    star
    345
  • Rank 122,750 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Delete Package Versions

This action deletes versions of a package from GitHub Packages. This action will only delete a maximum of 100 versions in one run.

What It Can Do

  • Create a retention policy (delete all except n most recent pre-release versions)
  • Delete all package versions except n most recent versions
  • Delete oldest version(s)
  • Ignore version(s) from deletion through regex
  • Delete version(s) of a package that is hosted from a repo having access to package
  • Delete version(s) of a package that is hosted from a repo not having access to package
  • Delete a single version
  • Delete multiple versions
  • Delete specific version(s)

Usage

- uses: actions/delete-package-versions@v4
  with:
  # Can be a single package version id, or a comma separated list of package version ids.
  # Defaults to an empty string.
  package-version-ids:

  # Owner of the package.
  # Defaults to the owner of the repo executing the workflow.
  # Required if deleting a version from a package hosted in a different org than the one executing the workflow.
  owner:

  # Name of the package.
  # Required
  package-name:

  # Type of the package. Can be one of container, maven, npm, nuget, or rubygems.
  # Required
  package-type:

  # The number of old versions to delete starting from the oldest version.
  # Defaults to 1.
  num-old-versions-to-delete:

  # The number of latest versions to keep.
  # This cannot be specified with `num-old-versions-to-delete`. By default, `min-versions-to-keep` takes precedence over `num-old-versions-to-delete`.
  # When set to 0, all deletable versions will be deleted.
  # When set greater than 0, all deletable package versions except the specified number will be deleted.
  min-versions-to-keep:

  # The package versions to exclude from deletion.
  # Takes regex for the version name as input.
  # By default nothing is ignored. This is ignored when `delete-only-pre-release-versions` is true
  ignore-versions:

  # If true it will delete only the pre-release versions.
  # The number of pre-release versions to keep can be set by using `min-versions-to-keep` value with this.
  # When `min-versions-to-keep` is 0, all pre-release versions get deleted.
  # Defaults to false.
  # Cannot be used with `num-old-versions-to-delete` and `ignore-versions`.
  delete-only-pre-release-versions:

  # If true it will delete only the untagged versions in case of container package.
  # Does not work for other package types and will be ignored.
  # The number of untagged versions to keep can be set by using `min-versions-to-keep` value with this.
  # When `min-versions-to-keep` is 0, all untagged versions get deleted.
  # Defaults to false.
  # Cannot be used with `num-old-versions-to-delete`.
  delete-only-untagged-versions:

  # The token used to authenticate with GitHub Packages.
  # Defaults to github.token.
  # Required if the repo running the workflow does not have access to delete the package.
  #   For rubygems and maven package, repo has access if package is hosted in the same repo as the workflow.
  #   For container, npm and nuget package, repo has access if assigned **Admin** role under Package Settings > Manage Actions Access.
  #   If `package-version-ids` is given the token only needs the delete packages scope.
  #   If `package-version-ids` is not given the token needs the delete packages scope and the read packages scope
  token:

Valid Input Combinations

owner, package-name, package-type and token can be used with the following combinations in a workflow -

  • num-old-versions-to-delete
  • min-versions-to-keep
  • delete-only-pre-release-versions
  • ignore-versions
  • num-old-versions-to-delete + ignore-versions
  • min-versions-to-keep + ignore-versions
  • min-versions-to-keep + delete-only-pre-release-versions
  • delete-only-untagged-versions
  • min-versions-to-keep + delete-only-untagged-versions

Scenarios

  • Delete Package Versions

  • Usage

  • Valid Input Combinations

  • Scenarios

  • License

    Delete all pre-release versions except y latest pre-release package versions

    To delete all pre release versions except y latest pre-release package versions, the package-name, min-versions-to-keep and delete-only-pre-release-versions inputs are required.

    Example

    Delete all pre-release package versions except latest 10

    - uses: actions/delete-package-versions@v4
      with: 
        package-name: 'test-package'
        package-type: 'npm'
        min-versions-to-keep: 10
        delete-only-pre-release-versions: "true"

    To delete all pre release versions except y latest pre-release package versions from a repo not having access to package, the owner, package-name, token, min-versions-to-keep and delete-only-pre-release-versions inputs are required.

    Example

    Delete all pre-release package versions except latest 10 from a repo not having access to package

    - uses: actions/delete-package-versions@v4
      with: 
        owner: 'github'
        package-name: 'test-package'
        package-type: 'npm'
        token: ${{ secrets.GITHUB_PAT }}
        min-versions-to-keep: 10
        delete-only-pre-release-versions: "true"

    Delete all untagged container versions except y latest untagged versions

    To delete all untagged versions of a container package except y latest untagged versions, the package-name, package-type, min-versions-to-keep and delete-only-untagged-versions inputs are required. package-type must be container for this scenario.

    Example

    Delete all untagged versions except latest 10

    - uses: actions/delete-package-versions@v4
      with: 
        package-name: 'test-package'
        package-type: 'container'
        min-versions-to-keep: 10
        delete-only-untagged-versions: 'true'

    Delete all except y latest versions while ignoring particular package versions

    To delete all except y latest versions while ignoring particular package versions, the package-name, min-versions-to-keep and ignore-versions inputs are required.

    Example

    Delete all except latest 3 package versions excluding major versions as per semver

    - uses: actions/delete-package-versions@v4
      with: 
        package-name: 'test-package'
        package-type: 'npm'
        min-versions-to-keep: 3
        ignore-versions: '^(0|[1-9]\\d*)\\.0\\.0$'

    To delete all except y latest versions while ignoring particular package versions from a repo not having access to package, the owner, package-name, token, min-versions-to-keep and ignore-versions inputs are required.

    The token needs the delete packages and read packages scope. It is recommended to store the token as a secret. In this example the token was stored as a secret named GITHUB_PAT.

    Example

    Delete all except latest 3 package versions excluding major versions as per semver from a repo not having access to package

    - uses: actions/delete-package-versions@v4
      with: 
        owner: 'github'
        package-name: 'test-package'
        package-type: 'npm'
        token: ${{ secrets.GITHUB_PAT }}
        min-versions-to-keep: 3
        ignore-versions: '^(0|[1-9]\\d*)\\.0\\.0$'

    Delete oldest x number of versions while ignoring particular package versions

    To delete oldest x number of versions while ignoring all the major package versions, the package-name, num-oldest-versions-to-delete and ignore-versions inputs are required.

    There is a possibility if the oldest x number of versions contain ignored package versions, actual package versions to get deleted will be less than x.

    Example

    Delete 3 oldest versions excluding major versions as per semver

    - uses: actions/delete-package-versions@v4
      with: 
        package-name: 'test-package'
        package-type: 'npm'
        num-old-versions-to-delete: 3
        ignore-versions: '^(0|[1-9]\\d*)\\.0\\.0$'

    To delete oldest x number of versions while ignoring all the major package versions from a repo not having access to package, the owner, package-name, token, num-oldest-versions-to-delete and ignore-versions inputs are required.

    There is a possibility if the oldest x number of versions contain ignored package versions, actual package versions to get deleted will be less than x.

    Example

    Delete 3 oldest versions excluding major versions as per semver from a repo not having access to package

    - uses: actions/delete-package-versions@v4
      with: 
        owner: 'github'
        package-name: 'test-package'
        package-type: 'npm'
        token: ${{ secrets.PAT }}
        num-old-versions-to-delete: 3
        ignore-versions: '^(0|[1-9]\\d*)\\.0\\.0$'

    Delete all except y latest versions of a package

    To delete all except y latest versions of a package hosted, the package-name and min-versions-to-keep inputs are required.

    Example

    Delete all except latest 2 versions of a package hosted

    - uses: actions/delete-package-versions@v4
      with:
        package-name: 'test-package'
        package-type: 'npm'
        min-versions-to-keep: 2

    To delete all except y latest versions of a package hosted from a repo not having access to package, the owner, package-name, token and min-versions-to-keep inputs are required.

    The token needs the delete packages and read packages scope. It is recommended to store the token as a secret. In this example the token was stored as a secret named GITHUB_PAT.

    Example

    Delete all except latest 2 versions of a package hosted from a repo not having access to package

    - uses: actions/delete-package-versions@v4
      with:
        owner: 'github'
        package-name: 'test-package'
        package-type: 'npm'
        token: ${{ secrets.PAT }}
        min-versions-to-keep: 2

    Delete oldest x number of versions of a package

    To delete the oldest x number of versions of a package hosted, the package-name, and num-old-versions-to-delete inputs are required.

    Example

    Delete the oldest 3 version of a package hosted

    - uses: actions/delete-package-versions@v4
      with:
        package-name: 'test-package'
        package-type: 'npm'
        num-old-versions-to-delete: 3

    To delete the oldest x number of versions of a package hosted from a repo not having access to package, the owner, package-name, token and num-old-versions-to-delete inputs are required.

    The token needs the delete packages and read packages scope. It is recommended to store the token as a secret. In this example the token was stored as a secret named GITHUB_PAT.

    Example

    Delete the oldest 3 version of a package hosted from a repo not having access to package

    - uses: actions/delete-package-versions@v4
      with:
        owner: 'github'
        package-name: 'test-package'
        package-type: 'npm'
        num-old-versions-to-delete: 3
        token: ${{ secrets.GITHUB_PAT }}

    Delete oldest version of a package

    To delete the oldest version of a package that is hosted, the package-name input is required.

    Example

    - uses: actions/delete-package-versions@v4
      with:
        package-name: 'test-package'
        package-type: 'npm'

    To delete the oldest version of a package that is hosted from a repo not having access to package, the owner, package-name, token inputs are required.

    Example

    - uses: actions/delete-package-versions@v4
      with:
        owner: 'github'
        package-name: 'test-package'
        package-type: 'npm'
        token: ${{ secrets.PAT }}

    Delete a specific version of a package

    To delete a specific version of a package that is hosted, the package-version-ids input is required.

    Package version ids can be retrieved via the GitHub REST API

    Example

    - uses: actions/delete-package-versions@v4
      with:
        package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
        package-name: 'test-package'
        package-type: 'npm'

    To delete a specific version of a package that is hosted from a repo not having access to package, the package-version-ids and token inputs are required.

    Package version ids can be retrieved via the GitHub REST API

    Example

    - uses: actions/delete-package-versions@v4
      with:
        package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
        package-name: 'test-package'
        package-type: 'npm'
        token: ${{ secrets.PAT }}

    Delete multiple specific versions of a package

    To delete multiple specific versions of a package that is hosted, the package-version-ids input is required.

    The package-version-ids input should be a comma separated string of package version ids. Package version ids can be retrieved via the GitHub REST API.

    Example

    - uses: actions/delete-package-versions@v4
      with:
        package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw'
        package-name: 'test-package'
        package-type: 'npm'

    To delete multiple specific versions of a package that is hosted from a repo not having access to package, the package-version-ids, token inputs are required.

    The package-version-ids input should be a comma separated string of package version ids. Package version ids can be retrieved via the GitHub REST API.

    Example

    - uses: actions/delete-package-versions@v4
      with:
        package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw'
        package-name: 'test-package'
        package-type: 'npm'
        token: ${{ secrets.PAT }}

License

The scripts and documentation in this project are released under the MIT License

More Repositories

1

runner-images

GitHub Actions runner images
PowerShell
9,683
star
2

starter-workflows

Accelerating new GitHub Actions workflows
TypeScript
8,687
star
3

toolkit

The GitHub ToolKit for developing GitHub Actions.
TypeScript
4,974
star
4

runner

The Runner for GitHub Actions πŸš€
C#
4,825
star
5

checkout

Action for checking out a repo
TypeScript
4,634
star
6

actions-runner-controller

Kubernetes controller for GitHub Actions self-hosted runners
Go
4,595
star
7

cache

Cache dependencies and build outputs in GitHub Actions
TypeScript
4,511
star
8

github-script

Write workflows scripting the GitHub API in JavaScript
TypeScript
4,184
star
9

setup-node

Set up your GitHub Actions workflow with a specific version of node.js
TypeScript
3,895
star
10

upload-artifact

TypeScript
3,162
star
11

typescript-action

Create a TypeScript Action with tests, linting, workflow, publishing, and versioning
TypeScript
2,001
star
12

labeler

An action for automatically labelling pull requests
TypeScript
1,941
star
13

setup-python

Set up your GitHub Actions workflow with a specific version of Python
TypeScript
1,702
star
14

setup-java

Set up your GitHub Actions workflow with a specific version of Java
TypeScript
1,517
star
15

setup-go

Set up your GitHub Actions workflow with a specific version of Go
TypeScript
1,391
star
16

stale

Marks issues and pull requests that have not had recent interaction
TypeScript
1,345
star
17

download-artifact

TypeScript
1,338
star
18

create-release

An Action to create releases via the GitHub Release API
JavaScript
1,333
star
19

javascript-action

Create a JavaScript Action with tests, linting, workflow, publishing, and versioning
JavaScript
966
star
20

setup-dotnet

Set up your GitHub Actions workflow with a specific version of the .NET core sdk
TypeScript
932
star
21

upload-release-asset

An Action to upload a release asset via the GitHub Release API
JavaScript
660
star
22

first-interaction

An action for filtering pull requests and issues from first-time contributors
JavaScript
648
star
23

dependency-review-action

A GitHub Action for detecting vulnerable dependencies and invalid licenses in your PRs
TypeScript
598
star
24

deploy-pages

GitHub Action to publish artifacts to GitHub Pages for deployments
JavaScript
555
star
25

add-to-project

Automate adding issues and pull requests to GitHub projects
TypeScript
455
star
26

gh-actions-cache

A GitHub (gh) CLI extension to manage the GitHub Actions caches being used in a GitHub repository.
Go
257
star
27

example-services

Example workflows using service containers
JavaScript
248
star
28

hello-world-javascript-action

A template to demonstrate how to build a JavaScript action.
JavaScript
230
star
29

container-action

Shell
185
star
30

heroku

GitHub Action for interacting with Heroku
HCL
179
star
31

setup-ruby

Set up your GitHub Actions workflow with a specific version of Ruby
TypeScript
173
star
32

upload-pages-artifact

A composite action for packaging and uploading an artifact that can be deployed to GitHub Pages.
Shell
171
star
33

hello-world-docker-action

A template to demonstrate how to build a Docker action.
Shell
162
star
34

setup-elixir

Set up your GitHub Actions workflow with OTP and Elixir
JavaScript
154
star
35

python-versions

Python builds for Actions Runner Images
PowerShell
148
star
36

container-toolkit-action

Template repo for creating container actions using https://github.com/actions/toolkit/
TypeScript
115
star
37

github

Wraps actions-toolkit into an Action for common GitHub automations.
JavaScript
103
star
38

actions-sync

This tool allows GHES administrators to sync Actions to their instances
Go
93
star
39

configure-pages

An action to enable Pages and extract various metadata about a site. It can also be used to configure various static site generators we support as starter workflows.
JavaScript
91
star
40

create-github-app-token

GitHub Action for creating a GitHub App Installation Access Token
JavaScript
86
star
41

http-client

A lightweight HTTP client optimized for use with actions, TypeScript with generics and async await.
TypeScript
72
star
42

setup-haskell

Set up your GitHub Actions workflow with a specific version of Haskell (GHC and Cabal)
TypeScript
71
star
43

node-versions

Node builds for Actions Runner Images
PowerShell
69
star
44

languageservices

Language services for GitHub Actions workflows and expressions.
TypeScript
67
star
45

jekyll-build-pages

A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages.
HTML
66
star
46

importer-labs

GitHub Actions Importer helps you plan and automate the migration of Azure DevOps, Bamboo, CircleCI, GitLab, Jenkins, and Travis CI pipelines to GitHub Actions.
Ruby
65
star
47

runner-container-hooks

Runner Container Hooks for GitHub Actions
TypeScript
58
star
48

partner-runner-images

About GitHub Actions runner images provided by 3rd parties
54
star
49

go-dependency-submission

Calculates dependencies for a Go build-target and submits the list to the Dependency Submission API
TypeScript
53
star
50

importer-issue-ops

GitHub Actions Importer helps you plan and automate the migration of Azure DevOps, Bamboo, CircleCI, GitLab, Jenkins, and Travis CI pipelines to GitHub Actions.
Ruby
49
star
51

publish-action

TypeScript
39
star
52

go-versions

Go releases for Actions Runner Images
PowerShell
39
star
53

reusable-workflows

Reusable workflows for developing actions
JavaScript
38
star
54

.github

30
star
55

humans.txt

An Action to list out the humans who help feed and tend the robots of GitHub Actions.
JavaScript
29
star
56

versions-package-tools

Libs and tools used to build all *-version tools for GitHub Actions
PowerShell
20
star
57

publish-immutable-action

A GitHub Action used for publishing an Action to ghcr.io as an OCI container.
TypeScript
20
star
58

virtual-environments-packages

Code and scripts used to automate delivery of tool packages used in virtual-environments.
17
star
59

action-versions

Shell
17
star
60

boost-versions

Boost builds for Actions Virtual Environments
PowerShell
5
star
61

alpine_nodejs

Workflow for redistribution of Node.JS for actions/runner
Dockerfile
5
star
62

anno-test

1
star