Giter Club home page Giter Club logo

delete-package-versions's Introduction

Delete Package Versions

This action deletes versions of a package from GitHub Packages except ghcr packages. This action will only delete a maximum of 99 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 in the same repo that is executing the workflow
  • Delete version(s) of a package that is hosted in a different repo than the one executing the workflow
  • Delete a single version
  • Delete multiple versions
  • Delete specific version(s)

Usage

- uses: actions/delete-package-versions@v2
  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 repo hosting the package.
  # Defaults to the owner of the repo executing the workflow.
  # Required if deleting a version from a package hosted in a different repo than the one executing the workflow.
  owner:

  # Repo hosting the package.
  # Defaults to the repo executing the workflow.
  # Required if deleting a version from a package hosted in a different repo than the one executing the workflow.
  repo:

  # Name of the package.
  # Defaults to an empty string.
  # Required if `package-version-ids` input is not given.
  package-name:

  # 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, `num-old-versions-to-delete` takes precedence over `min-versions-to-keep`.
  # 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.
  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:

  # The token used to authenticate with GitHub Packages.
  # Defaults to github.token.
  # Required if deleting a version from a package hosted in a different repo than the one executing the workflow.
  #   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, repo, package-name 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

Scenarios

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 in the same repo as the workflow 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 in the same repo as the workflow

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

To delete all pre release versions except y latest pre-release package versions in a different repo than the workflow the owner, repo, package-name, token, min-versions-to-keep and delete-only-pre-release-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 pre-release package versions except latest 10 in a different repo than the workflow

- uses: actions/delete-package-versions@v2
  with: 
    owner: 'github'
    repo: 'packages'
    package-name: 'test-package'
    token: ${{ secrets.GITHUB_PAT }}
    min-versions-to-keep: 10
    delete-only-pre-release-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 in the same repo as the workflow 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 in the same repo as the workflow

- uses: actions/delete-package-versions@v2
  with: 
    package-name: 'test-packae'
    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 in a different repo than the workflow the owner, repo, 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 in a different repo than the workflow

- uses: actions/delete-package-versions@v2
  with: 
    owner: 'github'
    repo: 'packages'
    package-name: 'test-packae'
    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 in the same repo as the workflow 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 is the same repo as the workflow

- uses: actions/delete-package-versions@v2
  with: 
    package-name: 'test-packae'
    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 in a different repo than the workflow the owner, repo, 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.

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 3 oldest versions excluding major versions as per semver is a differernt repo than the workflow

- uses: actions/delete-package-versions@v2
  with: 
    owner: 'github'
    repo: 'packages'
    package-name: 'test-packae'
    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 in the same repo as the workflow the package-name and min-versions-to-keep inputs are required.

Example

Delete all except latest 2 versions of a package hosted in the same repo as the workflow

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

To delete all except y latest versions of a package hosted in a repo other than the workflow the owner, repo, 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 in a repo other than the workflow

- uses: actions/delete-package-versions@v2
  with:
    owner: 'github'
    repo: 'packages'
    package-name: 'test-package'
    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 in the same repo as the workflow the package-name, and num-old-versions-to-delete inputs are required.

Example

Delete the oldest 3 version of a package hosted in the same repo as the workflow

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

To delete the oldest x number of versions of a package hosted in a different repo than the workflow the owner, repo, 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 in a different repo than the one executing the workflow

- uses: actions/delete-package-versions@v2
  with:
    owner: 'github'
    repo: 'packages'
    package-name: 'test-package'
    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 in the same repo as the workflow the package-name input is required.

Example

- uses: actions/delete-package-versions@v2
  with:
    package-name: 'test-package'

To delete the oldest version of a package that is hosted in a different repo than the workflow the owner, repo, package-name, token 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

- uses: actions/delete-package-versions@v2
  with:
    owner: 'github'
    repo: 'packages'
    package-name: 'test-package'
    token: ${{ secrets.PAT }}

Delete a specific version of a package

To delete a specific version of a package that is hosted in the same repo as the workflow the package-version-ids input is required.

Package version ids can be retrieved via the GitHub GraphQL API

Example

- uses: actions/delete-package-versions@v2
  with:
    package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'

To delete a specific version of a package that is hosted in a different repo than the workflow the package-version-ids and token 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.

Package version ids can be retrieved via the GitHub GraphQL API

Example

- uses: actions/delete-package-versions@v2
  with:
    package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
    token: ${{ secrets.PAT }}

Delete multiple specific versions of a package

To delete multiple specifc versions of a package that is hosted in the same repo as the workflow 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 GraphQL API.

Example

- uses: actions/delete-package-versions@v2
  with:
    package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw'

To delete multiple specifc versions of a package that is hosted in a repo other than the workflow 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 GraphQL API.

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

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

License

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

delete-package-versions's People

Contributors

namratajha avatar trent-j avatar dependabot[bot] avatar thboop avatar brcrista avatar chrispat avatar ralfstuckert avatar ericsciple avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.