Files
delete-package-versions/README.md
T

223 lines
9.1 KiB
Markdown
Raw Normal View History

2020-02-29 19:33:20 -06:00
# Delete Package Versions
2020-01-29 10:13:06 -05:00
2021-03-29 15:45:24 -07:00
**Please note:** This repository is currently unmaintained by a team of developers at GitHub. The
repository is here and you can use it as an example, or in Actions. However please be aware that
we are not going to be updating issues or pull requests on this repository.
**Maintained Actions:**
* [SmartsquareGmbH/delete-old-packages](https://github.com/SmartsquareGmbH/delete-old-packages)
To reflect this state weve marked this repository as Archived.
If you are having an issue or question about GitHub Actions then please [contact customer support](https://help.github.com/en/articles/about-github-actions#contacting-support).
If you have found a security issue [please submit it here](https://hackerone.com/github).
---
2020-07-21 08:13:33 -07:00
This action deletes versions of a package from [GitHub Packages](https://github.com/features/packages).
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
### What It Can Do
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
* Delete a single version
* Delete multiple versions
2020-07-21 08:13:33 -07:00
* Delete specific version(s)
2020-02-29 19:33:20 -06:00
* Delete oldest version(s)
* 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
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
# Usage
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
```yaml
- uses: actions/delete-package-versions@v1
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:
2020-07-21 08:13:33 -07:00
2020-02-29 19:33:20 -06:00
# 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 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:
```
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
# Scenarios
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
* [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 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 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 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 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 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 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)
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
### Delete a specific version of a package hosted in the same repo as the workflow
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
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.
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
Package version ids can be retrieved via the [GitHub GraphQL API][api]
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
__Example__
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
```yaml
- uses: actions/delete-package-versions@v1
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
2020-01-29 10:13:06 -05:00
```
2020-02-29 19:33:20 -06:00
<br>
### Delete a specific version of a package hosted in a different repo than the workflow
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.
2020-07-21 08:13:33 -07:00
Package version ids can be retrieved via the [GitHub GraphQL API][api].
2020-02-29 19:33:20 -06:00
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__.
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
__Example__
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
```yaml
- uses: actions/delete-package-versions@v1
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
token: ${{ secrets.GITHUB_PAT }}
```
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
<br>
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
### Delete multiple specific versions of a package hosted in the same repo as the workflow
2020-01-29 10:13:06 -05:00
2020-07-21 08:13:33 -07:00
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.
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
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].
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
__Example__
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
```yaml
- uses: actions/delete-package-versions@v1
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw'
2020-01-29 10:13:06 -05:00
```
2020-02-29 19:33:20 -06:00
<br>
### Delete multiple specific versions of a package hosted in a different repo than the workflow
2020-07-21 08:13:33 -07:00
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.
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
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].
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
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__.
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
__Example__
```yaml
- uses: actions/delete-package-versions@v1
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw'
token: ${{ secrets.GITHUB_PAT }}
2020-01-29 10:13:06 -05:00
```
2020-02-29 19:33:20 -06:00
<br>
### Delete oldest version of a package hosted in the same repo as the workflow
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.
__Example__
```yaml
- uses: actions/delete-package-versions@v1
with:
package-name: 'test-package'
2020-01-29 10:13:06 -05:00
```
2020-02-29 19:33:20 -06:00
<br>
### Delete oldest version 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 one executing the workflow the __package-name__, __owner__, __repo__, and __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__.
__Example__
```yaml
- uses: actions/delete-package-versions@v1
with:
owner: 'github'
repo: 'packages'
package-name: 'test-package'
token: ${{ secrets.GITHUB_PAT }}
2020-01-29 10:13:06 -05:00
```
2020-02-29 19:33:20 -06:00
<br>
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
### Delete oldest x number of versions of a package hosted in the same repo as the workflow
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
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.
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
__Example__
Delete the oldest 3 version of a package hosted in the same repo as the workflow
2020-01-29 10:13:06 -05:00
```yaml
2020-02-29 19:33:20 -06:00
- uses: actions/delete-package-versions@v1
with:
package-name: 'test-package'
num-old-versions-to-delete: 3
2020-01-29 10:13:06 -05:00
```
2020-02-29 19:33:20 -06:00
<br>
### Delete oldest x number of versions of a package hosted in a different repo than the workflow
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.
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__.
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
__Example__
2020-01-29 10:13:06 -05:00
2020-02-29 19:33:20 -06:00
Delete the oldest 3 version of a package hosted in a different repo than the one executing the workflow
2020-01-29 10:13:06 -05:00
```yaml
2020-02-29 19:33:20 -06:00
- uses: actions/delete-package-versions@v1
with:
owner: 'github'
2020-07-21 08:13:33 -07:00
repo: 'packages'
2020-02-29 19:33:20 -06:00
package-name: 'test-package'
num-old-versions-to-delete: 3
token: ${{ secrets.GITHUB_PAT }}
2020-01-29 10:13:06 -05:00
```
2020-02-29 19:33:20 -06:00
# License
2020-07-21 08:13:33 -07:00
The scripts and documentation in this project are released under the [MIT License](https://github.com/actions/delete-package-versions/blob/main/LICENSE)
2020-02-29 19:33:20 -06:00
[api]: https://developer.github.com/v4/previews/#github-packages
[token]: https://help.github.com/en/packages/publishing-and-managing-packages/about-github-packages#about-tokens
[secret]: https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets