diff --git a/README.md b/README.md index 470cf1d..775706d 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ This action deletes versions of a package from [GitHub Packages](https://github.com/features/packages). This action will only delete a maximum of 99 versions in one run. -_This action does currently not support deleting packages from the GitHub Container Registry. As the npm registry is about to be migrated to the same new architecture as GHCR, this action won't work for npm soon too (see [#74](https://github.com/actions/delete-package-versions/issues/74))._ - ### What It Can Do * Create a retention policy (delete all except n most recent pre-release versions) @@ -30,16 +28,14 @@ _This action does currently not support deleting packages from the GitHub Contai # 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. + # Required package-name: + # Type of the package. + # Required + package-type: + # The number of old versions to delete starting from the oldest version. # Defaults to 1. num-old-versions-to-delete: @@ -72,7 +68,7 @@ _This action does currently not support deleting packages from the GitHub Contai # Valid Input Combinations -`owner`, `repo`, `package-name` and `token` can be used with the following combinations in a workflow - +`owner`, `package-name` and `token` can be used with the following combinations in a workflow - - `num-old-versions-to-delete` - `min-versions-to-keep` @@ -106,10 +102,11 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 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 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. + To delete all pre release versions except y latest pre-release package versions in a different repo than the workflow the __owner__, __package-name__, __token__, __min-versions-to-keep__ and __delete-only-pre-release-versions__ inputs are required. The [token][token] needs the delete packages and read packages scope. It is recommended [to store the token as a secret][secret]. In this example the [token][token] was stored as a secret named __GITHUB_PAT__. @@ -121,8 +118,8 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 with: owner: 'github' - repo: 'packages' package-name: 'test-package' + package-type: 'npm' token: ${{ secrets.GITHUB_PAT }} min-versions-to-keep: 10 delete-only-pre-release-versions: "true" @@ -142,11 +139,12 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 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 in a different repo than the workflow the __owner__, __repo__, __package-name__, __token__, __min-versions-to-keep__ and __ignore-versions__ inputs are required. + To delete all except y latest versions while ignoring particular package versions in a different repo than the workflow the __owner__, __package-name__, __token__, __min-versions-to-keep__ and __ignore-versions__ inputs are required. The [token][token] needs the delete packages and read packages scope. It is recommended [to store the token as a secret][secret]. In this example the [token][token] was stored as a secret named __GITHUB_PAT__. @@ -158,8 +156,8 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 with: owner: 'github' - repo: 'packages' package-name: 'test-package' + package-type: 'npm' token: ${{ secrets.GITHUB_PAT }} min-versions-to-keep: 3 ignore-versions: '^(0|[1-9]\\d*)\\.0\\.0$' @@ -181,11 +179,12 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 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 in a different repo than the workflow the __owner__, __repo__, __package-name__, __token__, __num-oldest-versions-to-delete__ and __ignore-versions__ inputs are required. + To delete oldest x number of versions while ignoring all the major package versions in a different repo than the workflow 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. @@ -199,8 +198,8 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 with: owner: 'github' - repo: 'packages' package-name: 'test-package' + package-type: 'npm' token: ${{ secrets.PAT }} num-old-versions-to-delete: 3 ignore-versions: '^(0|[1-9]\\d*)\\.0\\.0$' @@ -220,10 +219,11 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 with: package-name: 'test-package' + package-type: 'npm' 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. + To delete all except y latest versions of a package hosted in a repo other than the workflow the __owner__, __package-name__, __token__ and __min-versions-to-keep__ inputs are required. The [token][token] needs the delete packages and read packages scope. It is recommended [to store the token as a secret][secret]. In this example the [token][token] was stored as a secret named __GITHUB_PAT__. @@ -235,8 +235,8 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 with: owner: 'github' - repo: 'packages' package-name: 'test-package' + package-type: 'npm' token: ${{ secrets.PAT }} min-versions-to-keep: 2 ``` @@ -255,10 +255,11 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 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 in a different repo than the workflow the __owner__, __repo__, __package-name__, __token__ and __num-old-versions-to-delete__ inputs are required. + To delete the oldest x number of versions of a package hosted in a different repo than the workflow the __owner__, __package-name__, __token__ and __num-old-versions-to-delete__ inputs are required. The [token][token] needs the delete packages and read packages scope. It is recommended [to store the token as a secret][secret]. In this example the [token][token] was stored as a secret named __GITHUB_PAT__. @@ -270,8 +271,8 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 with: owner: 'github' - repo: 'packages' package-name: 'test-package' + package-type: 'npm' num-old-versions-to-delete: 3 token: ${{ secrets.GITHUB_PAT }} ``` @@ -288,9 +289,10 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 with: package-name: 'test-package' + package-type: 'npm' ``` - 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. + To delete the oldest version of a package that is hosted in a different repo than the workflow the __owner__, __package-name__, __token__ inputs are required. The [token][token] needs the delete packages and read packages scope. It is recommended [to store the token as a secret][secret]. In this example the [token][token] was stored as a secret named __GITHUB_PAT__. @@ -300,8 +302,8 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 with: owner: 'github' - repo: 'packages' package-name: 'test-package' + package-type: 'npm' token: ${{ secrets.PAT }} ``` @@ -319,6 +321,8 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 with: package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3' + package-name: 'test-package' + package-type: 'npm' ``` 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. @@ -333,6 +337,8 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 with: package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3' + package-name: 'test-package' + package-type: 'npm' token: ${{ secrets.PAT }} ``` @@ -350,6 +356,8 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 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 in a repo other than the workflow the __package-version-ids__, __token__ inputs are required. @@ -364,6 +372,8 @@ _This action does currently not support deleting packages from the GitHub Contai - uses: actions/delete-package-versions@v3 with: package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw' + package-name: 'test-package' + package-type: 'npm' token: ${{ secrets.PAT }} ``` diff --git a/dist/index.js b/dist/index.js index 188675f..b396964 100644 --- a/dist/index.js +++ b/dist/index.js @@ -20,7 +20,7 @@ const rxjs_1 = __nccwpck_require__(5805); const operators_1 = __nccwpck_require__(7801); const version_1 = __nccwpck_require__(4428); const operators_2 = __nccwpck_require__(7801); -const RATE_LIMIT = 1; +const RATE_LIMIT = 99; let totalCount = 0; function getVersionIds(owner, packageName, packageType, numVersions, page, token) { return version_1.getOldestVersions(owner, packageName, packageType, numVersions, page, token).pipe(operators_2.expand(value => value.paginate diff --git a/src/delete.ts b/src/delete.ts index 64a11f7..b3f0cc2 100644 --- a/src/delete.ts +++ b/src/delete.ts @@ -10,7 +10,7 @@ import { } from './version' import {concatMap, map, expand, tap} from 'rxjs/operators' -const RATE_LIMIT = 1 +const RATE_LIMIT = 99 let totalCount = 0 export function getVersionIds(