Update README.md

This commit is contained in:
Namrata Jha
2021-11-23 10:28:51 +00:00
committed by GitHub
parent 6fee3def5e
commit 020712e298
+215 -177
View File
@@ -4,15 +4,17 @@ This action deletes versions of a package from [GitHub Packages](https://github.
### What It Can Do ### What It Can Do
* Delete a single version * Create a retention policy (delete all except n most recent pre-release versions)
* Delete multiple versions * Delete all package versions except n most recent versions.
* Delete specific version(s)
* Delete oldest version(s) * 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 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 version(s) of a package that is hosted in a different repo than the one executing the workflow
* Delete maximum possible package versions except n latest versions * Delete a single version
* Ignore some versions based on name from deletion * Delete multiple versions
* Delete only pre-release versions
* Delete specific version(s)
# Usage # Usage
@@ -40,18 +42,19 @@ This action deletes versions of a package from [GitHub Packages](https://github.
# The number of old versions to delete starting from the oldest version. # The number of old versions to delete starting from the oldest version.
# Defaults to 1. # Defaults to 1.
# Cannot be more than 100 # Cannot be more than 100.
num-old-versions-to-delete: num-old-versions-to-delete:
# The number of latest versions to not delete. # The number of latest versions to not delete.
# Defaults to 0. # Defaults to 0.
# When this is set greater than 0 it will delete all deletable package versions except the specified no. # When this is set greater than 0 it will delete all deletable package versions except the specified no.
# `num-old-versions-to-delete` will not be taken into account. # `num-old-versions-to-delete` will not be taken into account with this option.
# Cannot be more than 100 # Cannot be more than 100.
min-versions-to-keep: min-versions-to-keep:
# The package versions to ignore exclude from deletion. # The package versions to exclude from deletion.
# By default nothing is ignored # Takes regex for the version name as input.
# By default nothing is ignored.
ignore-versions: ignore-versions:
# If true it will delete only the pre-release versions. # If true it will delete only the pre-release versions.
@@ -70,253 +73,288 @@ This action deletes versions of a package from [GitHub Packages](https://github.
# Scenarios # Scenarios
- [Delete a specific version of a package hosted in the same repo as the workflow](#delete-a-specific-version-of-a-package-hosted-in-the-same-repo-as-the-workflow) - [Delete all pre-release versions except y latest pre-release package versions](#delete-all-pre-release-versions-except-y-latest-pre-release-package-versions)
- [Delete a specific version of a package hosted in a different repo than the workflow](#delete-a-specific-version-of-a-package-hosted-in-a-different-repo-than-the-workflow) - [Delete all except y latest versions while ignoring particular package versions](#delete-all-except-y-latest-versions-while-ignoring-particular-package-versions)
- [Delete multiple specific versions of a package hosted in the same repo as the workflow](#delete-multiple-specific-versions-of-a-package-hosted-in-the-same-repo-as-the-workflow) - [Delete oldest x number of versions while ignoring particular package versions](#delete-oldest-x-number-of-versions-while-ignoring-particular-package-versions)
- [Delete multiple specific versions of a package hosted in a different repo than the workflow](#delete-multiple-specific-versions-of-a-package-hosted-in-a-different-repo-than-the-workflow) - [Delete all except y latest versions of a package](#delete-all-except-y-latest-versions-of-a-package)
- [Delete oldest version of a package hosted in the same repo as the workflow](#delete-oldest-version-of-a-package-hosted-in-the-same-repo-as-the-workflow) - [Delete oldest x number of versions of a package](#delete-oldest-x-number-of-versions-of-a-package)
- [Delete oldest version of a package hosted in a different repo than the workflow](#delete-oldest-version-of-a-package-hosted-in-a-different-repo-than-the-workflow) - [Delete oldest version of a package](#delete-oldest-version-of-a-package)
- [Delete oldest x number of versions of a package hosted in the same repo as the workflow](#delete-oldest-x-number-of-versions-of-a-package-hosted-in-the-same-repo-as-the-workflow) - [Delete a specific version of a package](#delete-a-specific-version-of-a-package)
- [Delete oldest x number of versions of a package hosted in a different repo than the workflow](#delete-oldest-x-number-of-versions-of-a-package-hosted-in-a-different-repo-than-the-workflow) - [Delete multiple specific versions of a package](#delete-multiple-specific-versions-of-a-package)
- [Delete all except y latest versions of a package hosted in the same repo as the workflow](#delete-all-except-y-latest-versions-of-a-package-hosted-in-the-same-repo-as-the-workflow)
- [Delete all except y latest versions of a package hosted in a different repo than the workflow](#delete-all-except-y-latest-versions-of-a-package-hosted-in-a-different-repo-than-the-workflow)
- [Delete oldest x number of versions while ignoring particular package versions in the same repo as the workflow](#delete-oldest-x-number-of-versions-while-ignoring-particular-package-versions-in-the-same-repo-as-the-workflow)
- [Delete all except y latest versions while ignoring particular package versions in the same repo as the workflow](#delete-all-except-y-latest-versions-while-ignoring-particular-package-versions-in-the-same-repo-as-the-workflow)
- [Delete only pre-release package versions except y no of pre-release package versions in the same repo as the workflow](#delete-only-pre-release-package-versions-except-y-no-of-pre-release-package-versions-in-the-same-repo-as-the-workflow)
### Delete a specific version of a package hosted in the same repo as the workflow ### Delete all pre-release versions except y latest pre-release package versions
To delete a specific version of a package that is hosted in the same repo as the one executing the workflow the __package-version-ids__ input is required. 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.
Package version ids can be retrieved via the [GitHub GraphQL API][api] __Example__
__Example__ Delete all pre-release package versions except latest 10 in the same repo as the workflow
```yaml ```yaml
- uses: actions/delete-package-versions@v1 - uses: actions/delete-package-versions@v1
with: with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3' 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.
<br> 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__.
### Delete a specific version of a package hosted in a different repo than the workflow __Example__
To delete a specific version of a package that is hosted in a different repo than the one executing the workflow the __package-version-ids__, and __token__ inputs are required. Delete all pre-release package versions except latest 10 in a different repo than the workflow
Package version ids can be retrieved via the [GitHub GraphQL API][api]. ```yaml
- uses: actions/delete-package-versions@v1
with:
owner: 'github'
repo: 'packages'
package-name: 'test-package'
token: ${{ secrets.GITHUB_PAT }}
min-versions-to-keep: 10
delete-only-pre-release-versions: "true"
```
The [token][token] only needs the delete 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__. <br>
__Example__ ### Delete all except y latest versions while ignoring particular package versions
```yaml 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.
- uses: actions/delete-package-versions@v1
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
token: ${{ secrets.GITHUB_PAT }}
```
<br> __Example__
### Delete multiple specific versions of a package hosted in the same repo as the workflow Delete all except latest 3 package versions excluding major versions as per semver in the same repo as the workflow
To delete multiple specifc versions of a package that is hosted in the same repo that is executing the workflow the __package-version-ids__ input is required. ```yaml
- uses: actions/delete-package-versions@v1
with:
package-name: 'test-packae'
min-versions-to-keep: 3
ignore-versions: '^(0|[1-9]\\d*)\\.0\\.0$'
```
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][api]. 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.
__Example__ 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__.
```yaml __Example__
- uses: actions/delete-package-versions@v1
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw'
```
<br> Delete all except latest 3 package versions excluding major versions as per semver in a different repo than the workflow
### Delete multiple specific versions of a package hosted in a different repo than the workflow ```yaml
- uses: actions/delete-package-versions@v1
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$'
```
To delete multiple specifc versions of a package that is hosted in a different repo than the one executing the workflow the __package-version-ids__, and __token__ inputs are required. <br>
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][api]. ### Delete oldest x number of versions while ignoring particular package versions
The [token][token] only needs the delete 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__. 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.
__Example__ 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.
```yaml __Example__
- uses: actions/delete-package-versions@v1
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw'
token: ${{ secrets.GITHUB_PAT }}
```
<br> Delete 3 oldest versions excluding major versions as per semver is the same repo as the workflow
### Delete oldest version of a package hosted in the same repo as the workflow ```yaml
- uses: actions/delete-package-versions@v1
with:
package-name: 'test-packae'
num-old-versions-to-delete: 3
ignore-versions: '^(0|[1-9]\\d*)\\.0\\.0$'
```
To delete the oldest version of a package that is hosted in the same repo that is executing the workflow the __package-name__ input is required. 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.
__Example__ 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.
```yaml 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__.
- uses: actions/delete-package-versions@v1
with:
package-name: 'test-package'
```
<br> __Example__
### Delete oldest version of a package hosted in a different repo than the workflow Delete 3 oldest versions excluding major versions as per semver is a differernt repo than the workflow
To delete the oldest version of a package that is hosted in a different repo than the one executing the workflow the __package-name__, __owner__, __repo__, and __token__ inputs are required. ```yaml
- uses: actions/delete-package-versions@v1
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$'
```
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__. <br>
__Example__ ### Delete all except y latest versions of a package
```yaml 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.
- uses: actions/delete-package-versions@v1
with:
owner: 'github'
repo: 'packages'
package-name: 'test-package'
token: ${{ secrets.GITHUB_PAT }}
```
<br> __Example__
### Delete oldest x number of versions of a package hosted in the same repo as the workflow Delete all except latest 2 versions of a package hosted in the same repo as the workflow
To delete the oldest x number of versions of a package hosted in the same repo that is executing the workflow the __package-name__, and __num-old-versions-to-delete__ inputs are required. ```yaml
- uses: actions/delete-package-versions@v1
with:
package-name: 'test-package'
min-versions-to-keep: 2
```
__Example__ 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.
Delete the oldest 3 version of a package hosted in the same repo as the workflow 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__.
```yaml __Example__
- uses: actions/delete-package-versions@v1
with:
package-name: 'test-package'
num-old-versions-to-delete: 3
```
<br> Delete all except latest 2 versions of a package hosted in a repo other than the workflow
### Delete oldest x number of versions of a package hosted in a different repo than the workflow ```yaml
- uses: actions/delete-package-versions@v1
with:
owner: 'github'
repo: 'packages'
package-name: 'test-package'
token: ${{ secrets.PAT }}
min-versions-to-keep: 2
```
To delete the oldest x number of versions of a package hosted in a different repo than the one executing the workflow the __package-name__, __num-old-versions-to-delete__, __owner__, __repo__, and __token__ inputs are required. <br>
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__. ### Delete oldest x number of versions of a package
__Example__ 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.
Delete the oldest 3 version of a package hosted in a different repo than the one executing the workflow __Example__
```yaml Delete the oldest 3 version of a package hosted in the same repo as the workflow
- uses: actions/delete-package-versions@v1
with:
owner: 'github'
repo: 'packages'
package-name: 'test-package'
num-old-versions-to-delete: 3
token: ${{ secrets.GITHUB_PAT }}
```
<br> ```yaml
- uses: actions/delete-package-versions@v1
with:
package-name: 'test-package'
num-old-versions-to-delete: 3
```
### Delete all except y latest versions of a package hosted in the same repo as the workflow 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 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. 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__.
__Example__ __Example__
Delete all except latest 2 versions of a package hosted in the same repo as the workflow Delete the oldest 3 version of a package hosted in a different repo than the one executing the workflow
```yaml ```yaml
- uses: actions/delete-package-versions@v1 - uses: actions/delete-package-versions@v1
with: with:
package-name: 'test-package' owner: 'github'
min-versions-to-keep: 2 repo: 'packages'
``` package-name: 'test-package'
num-old-versions-to-delete: 3
token: ${{ secrets.GITHUB_PAT }}
```
<br> <br>
### Delete all except y latest versions of a package hosted in a different repo than the workflow ### Delete oldest version of a package
To delete oldest x number of versions while keeping minimum y latest versions of a package hosted in a different repo than the workflow the __package-name__, __min-versions-to-keep__, __owner__, __repo__, and __token__ inputs are required. To delete the oldest version of a package that is hosted in the same repo as the workflow the __package-name__ input is 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__. __Example__
__Example__ ```yaml
- uses: actions/delete-package-versions@v1
with:
package-name: 'test-package'
```
Delete all excpet latest 2 versions of a package hosted in a different repo than the workflow 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.
```yaml 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__.
- uses: actions/delete-package-versions@v1
with:
owner: 'github'
repo: 'packages'
package-name: 'test-package'
min-versions-to-keep: 2
token: ${{ secrets.GITHUB_PAT }}
```
<br> __Example__
### Delete oldest x number of versions while ignoring particular package versions in the same repo as the workflow ```yaml
- uses: actions/delete-package-versions@v1
with:
owner: 'github'
repo: 'packages'
package-name: 'test-package'
token: ${{ secrets.PAT }}
```
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. <br>
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. ### Delete a specific version of a package
__Example__ 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.
Delete 3 oldest versions excluding major versions as per semver is the same repo as the workflow Package version ids can be retrieved via the [GitHub GraphQL API][api]
```yaml __Example__
- uses: actions/delete-package-versions@v1
with:
package-name: 'test-packae'
num-old-versions-to-delete: 3
ignore-versions: '^(0|[1-9]\\d*)\\.0\\.0$'
```
<br> ```yaml
- uses: actions/delete-package-versions@v1
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
```
### Delete all except y latest versions while ignoring particular package versions in the same repo as the workflow 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.
To delete all except y latest versions while ignoring all the major package versions in the same repo as the workflow the __package-name__, __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__.
__Example__ Package version ids can be retrieved via the [GitHub GraphQL API][api]
Delete all except latest 3 package versions excluding major versions as per semver is the same repo as the workflow __Example__
```yaml ```yaml
- uses: actions/delete-package-versions@v1 - uses: actions/delete-package-versions@v1
with: with:
package-name: 'test-packae' package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
min-versions-to-keep: 3 token: ${{ secrets.PAT }}
ignore-versions: '^(0|[1-9]\\d*)\\.0\\.0$' ```
```
### Delete only pre-release package versions except y no of pre-release package versions in the same repo as the workflow <br>
To delete all pre release package versions except y no of 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. ### Delete multiple specific versions of a package
__Example__ 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.
Delete all pre-release package versions except latest 10 in the same repo as the workflow 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][api].
```yaml __Example__
- uses: actions/delete-package-versions@v1
with: ```yaml
package-name: 'test-package' - uses: actions/delete-package-versions@v1
min-versions-to-keep: 10 with:
delete-only-pre-release-versions: "true" 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][api].
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__.
__Example__
```yaml
- uses: actions/delete-package-versions@v1
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw'
token: ${{ secrets.PAT }}
```
# License # License