Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
delete

GitHub Action

Delete old packages

v0.4.0

Delete old packages

delete

Delete old packages

Deletes old package versions

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Delete old packages

uses: SmartsquareGmbH/[email protected]

Learn more about this action in SmartsquareGmbH/delete-old-packages

Choose a version

Delete old packages

GitHub action for deleting old versions of packages in the GitHub package registry.

This is very similar to actions/delete-package-versions but targets a different use case.

The action works by getting at most 20 packages with at most the oldest 100 versions of each, applying the filters (see table below) on them and then deleting the matching versions.

If you have more than 100 versions and none of the 100 oldest versions match, no packages will be deleted!

Inputs

Name Description Required Default
owner Owner of the repo containing the package(s) Set by GitHub
repo Repo containing the package(s) Set by GitHub
user User containing the package(s)
organization Organization containing the package(s)
names Names of the packages ✔️
semver-pattern Semver range of the versions ^.+$
version-pattern Regex pattern of the versions
version Specific version to delete
keep Number of versions to exclude from deletions 2
token Token with the necessary scopes to delete package versions Set by GitHub
dry-run If the action should only print what it would do. false

⚠️ You can provide either owner and repo, user or organization. An error is thrown for invalid combinations.

⚠️ You can provide either version, semver-pattern or version-pattern. An error is thrown for invalid combinations.

⚠️ keep can not be set when version is set.

Example usage

Delete old versions of the packages "package-1" and "package-2" for the current repository.

uses: smartsquaregmbh/[email protected]
with:
  names: |
    package-1
    package-2

Delete old versions of the packages "package-1" and "package-2" for the organization "my-organization".

uses: smartsquaregmbh/[email protected]
with:
  organization: my-organization
  names: |
    package-1
    package-2

Delete old versions in the form of "1.0.0-RC1" of the package "package".

uses: smartsquaregmbh/[email protected]
with:
  version-pattern: "^\\d+\\.\\d+\\.\\d+-RC\\d+$" # The regex needs to be escaped!
  names: |
    package

Delete old versions with a lower semver version than 2.x of the package "package".

uses: smartsquaregmbh/[email protected]
with:
  semver-pattern: "<2.x"
  names: |
    package

Delete old versions of the package "package" but keep at least 5 versions.

uses: smartsquaregmbh/[email protected]
with:
  keep: 5
  names: |
    package

Delete version foo-bar of the package "package".

uses: smartsquaregmbh/[email protected]
with:
  version: foo-bar
  names: |
    package