Compare commits
55 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fc4c9fe912 | |||
| b19f4fe385 | |||
| 020712e298 | |||
| 6fee3def5e | |||
| 32b30cfe62 | |||
| b5e80e74e4 | |||
| 7f40a506a4 | |||
| 8d3af2ed69 | |||
| 2dc6d27141 | |||
| e73aee77b1 | |||
| 79a5c93b7a | |||
| 0de5ea0608 | |||
| 1ea7a488b4 | |||
| 031ff897b2 | |||
| 7fdaaf4f60 | |||
| 799007d5ff | |||
| 4ec126b8cc | |||
| bd624e4936 | |||
| 90bcbbe553 | |||
| b5e7ea46fa | |||
| 1f8196ebbc | |||
| 398a50a9bf | |||
| 18061036ba | |||
| 0739f428e7 | |||
| 7ffc8a599c | |||
| 90fbe9a212 | |||
| 5349e7dc4e | |||
| 417214b728 | |||
| e50524f7ea | |||
| bedb90f12a | |||
| 7fa0e1f9f7 | |||
| 1b66f3e643 | |||
| 81656b7f86 | |||
| 6badf80095 | |||
| 2767d0ec96 | |||
| 4d5c009cd3 | |||
| f891cc8158 | |||
| 1e1d9c526f | |||
| e67c4fe012 | |||
| bcb7bb9bf4 | |||
| 8c6e47eb07 | |||
| 46494d7b74 | |||
| e9abcd8083 | |||
| a88602f068 | |||
| 5bd21282ee | |||
| d5a0427147 | |||
| e9da08677e | |||
| eac9ac793e | |||
| f0a2fa531f | |||
| 70375d9b94 | |||
| c38a6af07e | |||
| 5b1dcd4637 | |||
| a9df53edc6 | |||
| b055f56132 | |||
| ace7b23b09 |
@@ -0,0 +1,51 @@
|
||||
# `dist/index.js` is a special file in Actions.
|
||||
# When you reference an action with `uses:` in a workflow,
|
||||
# `index.js` is the code that will run.
|
||||
# For our project, we generate this file through a build process
|
||||
# from other source files.
|
||||
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
|
||||
name: Check dist/
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-dist:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set Node.js 12.x
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12.x
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Rebuild the index.js file
|
||||
run: npm run build
|
||||
|
||||
- name: Compare the expected and actual dist/ directories
|
||||
run: |
|
||||
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
||||
echo "Detected uncommitted changes after build. See status below:"
|
||||
git diff
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If dist/ was different than expected, upload the expected version as an artifact
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||
with:
|
||||
name: dist
|
||||
path: dist/
|
||||
@@ -1,8 +1,12 @@
|
||||
name: Licensed
|
||||
|
||||
on:
|
||||
push: {branches: main}
|
||||
pull_request: {branches: main}
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
test:
|
||||
@@ -17,4 +21,4 @@ jobs:
|
||||
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.12.2/licensed-2.12.2-linux-x64.tar.gz
|
||||
sudo tar -xzf licensed.tar.gz
|
||||
sudo mv licensed /usr/local/bin/licensed
|
||||
- run: licensed status
|
||||
- run: licensed status
|
||||
|
||||
@@ -30,4 +30,5 @@ jobs:
|
||||
name: Smoke Test Delete Package Versions Action
|
||||
with:
|
||||
package-name: 'com.github.actions.test-package'
|
||||
num-old-versions-to-delete: 0
|
||||
num-old-versions-to-delete: 0
|
||||
min-versions-to-keep: 0
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@actions/core"
|
||||
version: 1.2.0
|
||||
version: 1.6.0
|
||||
type: npm
|
||||
summary: Actions core lib
|
||||
homepage: https://github.com/actions/toolkit/tree/master/packages/core
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
---
|
||||
name: "@actions/http-client-1.0.11"
|
||||
version: 1.0.11
|
||||
type: npm
|
||||
summary: Actions Http Client
|
||||
homepage: https://github.com/actions/http-client#readme
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
||||
Generated
+1
-1
@@ -1,5 +1,5 @@
|
||||
---
|
||||
name: "@actions/http-client"
|
||||
name: "@actions/http-client-1.0.8"
|
||||
version: 1.0.8
|
||||
type: npm
|
||||
summary: Actions Http Client
|
||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: node-fetch
|
||||
version: 2.6.0
|
||||
version: 2.6.5
|
||||
type: npm
|
||||
summary: A light-weight module that brings window.fetch to node.js
|
||||
homepage: https://github.com/bitinn/node-fetch
|
||||
|
||||
Generated
+28
@@ -0,0 +1,28 @@
|
||||
---
|
||||
name: "tr46"
|
||||
version: 0.0.3
|
||||
type: npm
|
||||
summary: An JavaScript implementation of Unicode Technical Standard #46: Unicode IDNA Compatibility Processing.
|
||||
homepage: https://github.com/jsdom/tr46#readme
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE.md
|
||||
text: |
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
||||
Generated
+23
@@ -0,0 +1,23 @@
|
||||
---
|
||||
name: "webidl-conversions"
|
||||
version: 3.0.1
|
||||
type: npm
|
||||
summary: Implements the Web IDL algorithms for converting to and from JavaScript values
|
||||
homepage: https://github.com/jsdom/webidl-conversions#readme
|
||||
license: bsd-2-clause
|
||||
licenses:
|
||||
- sources: LICENSE.md
|
||||
text: |
|
||||
All rights reserved.
|
||||
|
||||
BSD 2-Clause License
|
||||
|
||||
Copyright (c) 2014, Domenic Denicola All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
Generated
+28
@@ -0,0 +1,28 @@
|
||||
---
|
||||
name: "whatwg-url"
|
||||
version: 5.0.0
|
||||
type: npm
|
||||
summary: An implementation of the WHATWG URL Standard in JavaScript
|
||||
homepage: https://github.com/jsdom/whatwg-url#readme
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE.md
|
||||
text: |
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
notices: []
|
||||
@@ -0,0 +1 @@
|
||||
* @actions/packages
|
||||
@@ -4,17 +4,22 @@ This action deletes versions of a package from [GitHub Packages](https://github.
|
||||
|
||||
### What It Can Do
|
||||
|
||||
* Delete a single version
|
||||
* Delete multiple versions
|
||||
* Delete specific version(s)
|
||||
* 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
|
||||
|
||||
```yaml
|
||||
- uses: actions/delete-package-versions@v1
|
||||
- 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.
|
||||
@@ -37,8 +42,27 @@ This action deletes versions of a package from [GitHub Packages](https://github.
|
||||
|
||||
# The number of old versions to delete starting from the oldest version.
|
||||
# Defaults to 1.
|
||||
# Cannot be more than 100.
|
||||
num-old-versions-to-delete:
|
||||
|
||||
# The number of latest versions to not delete.
|
||||
# Defaults to 0.
|
||||
# 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 with this option.
|
||||
# Cannot be more than 100.
|
||||
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.
|
||||
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.
|
||||
@@ -49,153 +73,288 @@ This action deletes versions of a package from [GitHub Packages](https://github.
|
||||
|
||||
# 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 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)
|
||||
- [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 all except y latest versions while ignoring particular package versions](#delete-all-except-y-latest-versions-while-ignoring-particular-package-versions)
|
||||
- [Delete oldest x number of versions while ignoring particular package versions](#delete-oldest-x-number-of-versions-while-ignoring-particular-package-versions)
|
||||
- [Delete all except y latest versions of a package](#delete-all-except-y-latest-versions-of-a-package)
|
||||
- [Delete oldest x number of versions of a package](#delete-oldest-x-number-of-versions-of-a-package)
|
||||
- [Delete oldest version of a package](#delete-oldest-version-of-a-package)
|
||||
- [Delete a specific version of a package](#delete-a-specific-version-of-a-package)
|
||||
- [Delete multiple specific versions of a package](#delete-multiple-specific-versions-of-a-package)
|
||||
|
||||
|
||||
### 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
|
||||
- uses: actions/delete-package-versions@v1
|
||||
with:
|
||||
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
|
||||
```
|
||||
```yaml
|
||||
- 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.
|
||||
|
||||
<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@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"
|
||||
```
|
||||
|
||||
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
|
||||
- uses: actions/delete-package-versions@v1
|
||||
with:
|
||||
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
|
||||
token: ${{ secrets.GITHUB_PAT }}
|
||||
```
|
||||
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.
|
||||
|
||||
<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@v2
|
||||
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
|
||||
- uses: actions/delete-package-versions@v1
|
||||
with:
|
||||
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw'
|
||||
```
|
||||
__Example__
|
||||
|
||||
<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@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$'
|
||||
```
|
||||
|
||||
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
|
||||
- uses: actions/delete-package-versions@v1
|
||||
with:
|
||||
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw'
|
||||
token: ${{ secrets.GITHUB_PAT }}
|
||||
```
|
||||
__Example__
|
||||
|
||||
<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@v2
|
||||
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
|
||||
- uses: actions/delete-package-versions@v1
|
||||
with:
|
||||
package-name: 'test-package'
|
||||
```
|
||||
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 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@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$'
|
||||
```
|
||||
|
||||
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
|
||||
- uses: actions/delete-package-versions@v1
|
||||
with:
|
||||
owner: 'github'
|
||||
repo: 'packages'
|
||||
package-name: 'test-package'
|
||||
token: ${{ secrets.GITHUB_PAT }}
|
||||
```
|
||||
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.
|
||||
|
||||
<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@v2
|
||||
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
|
||||
- uses: actions/delete-package-versions@v1
|
||||
with:
|
||||
package-name: 'test-package'
|
||||
num-old-versions-to-delete: 3
|
||||
```
|
||||
__Example__
|
||||
|
||||
<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@v2
|
||||
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
|
||||
- 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 }}
|
||||
```
|
||||
Delete the oldest 3 version of a package hosted in the same repo as the workflow
|
||||
|
||||
```yaml
|
||||
- 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][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__
|
||||
|
||||
Delete the oldest 3 version of a package hosted in a different repo than the one executing the workflow
|
||||
|
||||
```yaml
|
||||
- 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 }}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### 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__
|
||||
|
||||
```yaml
|
||||
- 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][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@v2
|
||||
with:
|
||||
owner: 'github'
|
||||
repo: 'packages'
|
||||
package-name: 'test-package'
|
||||
token: ${{ secrets.PAT }}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### 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][api]
|
||||
|
||||
__Example__
|
||||
|
||||
```yaml
|
||||
- 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][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__.
|
||||
|
||||
Package version ids can be retrieved via the [GitHub GraphQL API][api]
|
||||
|
||||
__Example__
|
||||
|
||||
```yaml
|
||||
- uses: actions/delete-package-versions@v2
|
||||
with:
|
||||
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
|
||||
token: ${{ secrets.PAT }}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### 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][api].
|
||||
|
||||
__Example__
|
||||
|
||||
```yaml
|
||||
- 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][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@v2
|
||||
with:
|
||||
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw'
|
||||
token: ${{ secrets.PAT }}
|
||||
```
|
||||
|
||||
# License
|
||||
|
||||
|
||||
+27
-19
@@ -7,7 +7,7 @@ describe.skip('index tests -- call graphql', () => {
|
||||
|
||||
getVersionIds(getInput({numOldVersionsToDelete: numVersions})).subscribe(
|
||||
ids => {
|
||||
expect(ids.length).toBe(numVersions)
|
||||
expect(ids.length).toBeLessThanOrEqual(numVersions)
|
||||
done()
|
||||
}
|
||||
)
|
||||
@@ -18,7 +18,7 @@ describe.skip('index tests -- call graphql', () => {
|
||||
|
||||
getVersionIds(getInput({numOldVersionsToDelete: numVersions})).subscribe(
|
||||
ids => {
|
||||
expect(ids.length).toBe(numVersions)
|
||||
expect(ids.length).toBeLessThanOrEqual(numVersions)
|
||||
done()
|
||||
}
|
||||
)
|
||||
@@ -57,31 +57,39 @@ describe.skip('index tests -- call graphql', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('deleteVersions test -- delete oldest version', done => {
|
||||
deleteVersions(getInput({numOldVersionsToDelete: 1})).subscribe(
|
||||
isSuccess => {
|
||||
expect(isSuccess).toBe(true)
|
||||
done()
|
||||
}
|
||||
)
|
||||
it.skip('deleteVersions test -- delete oldest version', done => {
|
||||
deleteVersions(
|
||||
getInput({numOldVersionsToDelete: 2, minVersionsToKeep: 1})
|
||||
).subscribe(isSuccess => {
|
||||
expect(isSuccess).toBe(true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('deleteVersions test -- delete 3 oldest versions', done => {
|
||||
deleteVersions(getInput({numOldVersionsToDelete: 3})).subscribe(
|
||||
isSuccess => {
|
||||
expect(isSuccess).toBe(true)
|
||||
done()
|
||||
}
|
||||
)
|
||||
it.skip('deleteVersions test -- delete 3 oldest versions', done => {
|
||||
deleteVersions(
|
||||
getInput({numOldVersionsToDelete: 3, minVersionsToKeep: 1})
|
||||
).subscribe(isSuccess => {
|
||||
expect(isSuccess).toBe(true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('deleteVersions test -- keep 5 versions', done => {
|
||||
deleteVersions(getInput({minVersionsToKeep: 5})).subscribe(isSuccess => {
|
||||
expect(isSuccess).toBe(true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
const defaultInput: InputParams = {
|
||||
packageVersionIds: [],
|
||||
owner: 'trent-j',
|
||||
repo: 'actions-testing',
|
||||
packageName: 'com.github.trent-j.actions-test',
|
||||
owner: 'namratajha',
|
||||
repo: 'only-pkg',
|
||||
packageName: 'onlypkg.maven',
|
||||
numOldVersionsToDelete: 1,
|
||||
minVersionsToKeep: 1,
|
||||
token: process.env.GITHUB_TOKEN as string
|
||||
}
|
||||
|
||||
|
||||
@@ -49,9 +49,9 @@ interface Params {
|
||||
}
|
||||
|
||||
const defaultParams = {
|
||||
owner: 'trent-j',
|
||||
repo: 'actions-testing',
|
||||
packageName: 'com.github.trent-j.actions-test',
|
||||
owner: 'namratajha',
|
||||
repo: 'only-pkg',
|
||||
packageName: 'onlypkg.maven',
|
||||
numVersions: 3,
|
||||
token: process.env.GITHUB_TOKEN as string
|
||||
}
|
||||
|
||||
+22
@@ -34,6 +34,28 @@ inputs:
|
||||
required: false
|
||||
default: "1"
|
||||
|
||||
min-versions-to-keep:
|
||||
description: >
|
||||
Number of versions to keep starting with the latest version
|
||||
Defaults to 0.
|
||||
required: false
|
||||
default: "0"
|
||||
|
||||
ignore-versions:
|
||||
description: >
|
||||
Regex pattern for package versions to ignore.
|
||||
Defaults to delete all versions.
|
||||
required: false
|
||||
default: "^$"
|
||||
|
||||
delete-only-pre-release-versions:
|
||||
description: >
|
||||
Deletes only pre-release versions upto. The number of pre-release versions to keep can be specified by min-versions-to-keep.
|
||||
When this is set num-old-versions-to-delete and ignore-versions will not be taken into account.
|
||||
By default this is set to false
|
||||
required: false
|
||||
default: "false"
|
||||
|
||||
token:
|
||||
description: >
|
||||
Token with the necessary scopes to delete package versions.
|
||||
|
||||
Vendored
+24137
-21111
File diff suppressed because one or more lines are too long
Generated
+6472
-3153
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -24,7 +24,7 @@
|
||||
"author": "YourNameOrOrganization",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.0",
|
||||
"@actions/core": "^1.6.0",
|
||||
"@actions/github": "^2.1.1",
|
||||
"rxjs": "^6.5.4"
|
||||
},
|
||||
@@ -32,15 +32,15 @@
|
||||
"@types/jest": "^24.0.23",
|
||||
"@types/node": "^12.7.12",
|
||||
"@typescript-eslint/parser": "^2.8.0",
|
||||
"@zeit/ncc": "^0.20.5",
|
||||
"@vercel/ncc": "^0.31.1",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-plugin-github": "^2.0.0",
|
||||
"eslint-plugin-jest": "^22.21.0",
|
||||
"jest": "^24.9.0",
|
||||
"jest-circus": "^24.9.0",
|
||||
"jest": "^27.3.1",
|
||||
"jest-circus": "^27.3.1",
|
||||
"js-yaml": "^3.13.1",
|
||||
"prettier": "^1.19.1",
|
||||
"ts-jest": "^24.2.0",
|
||||
"ts-jest": "^27.0.7",
|
||||
"typescript": "^3.6.4"
|
||||
}
|
||||
}
|
||||
|
||||
+23
-2
@@ -13,9 +13,30 @@ export function getVersionIds(input: Input): Observable<string[]> {
|
||||
input.owner,
|
||||
input.repo,
|
||||
input.packageName,
|
||||
input.numOldVersionsToDelete,
|
||||
input.numOldVersionsToDelete + input.minVersionsToKeep,
|
||||
input.token
|
||||
).pipe(map(versionInfo => versionInfo.map(info => info.id)))
|
||||
).pipe(
|
||||
map(versionInfo => {
|
||||
const numberVersionsToDelete =
|
||||
versionInfo.length - input.minVersionsToKeep
|
||||
|
||||
if (input.minVersionsToKeep > 0) {
|
||||
return numberVersionsToDelete <= 0
|
||||
? []
|
||||
: versionInfo
|
||||
.filter(info => !input.ignoreVersions.test(info.version))
|
||||
.map(info => info.id)
|
||||
.slice(0, -input.minVersionsToKeep)
|
||||
} else {
|
||||
return numberVersionsToDelete <= 0
|
||||
? []
|
||||
: versionInfo
|
||||
.filter(info => !input.ignoreVersions.test(info.version))
|
||||
.map(info => info.id)
|
||||
.slice(0, numberVersionsToDelete)
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
return throwError(
|
||||
|
||||
@@ -4,7 +4,10 @@ export interface InputParams {
|
||||
repo?: string
|
||||
packageName?: string
|
||||
numOldVersionsToDelete?: number
|
||||
minVersionsToKeep?: number
|
||||
ignoreVersions?: RegExp
|
||||
token?: string
|
||||
deletePreReleaseVersions?: string
|
||||
}
|
||||
|
||||
const defaultParams = {
|
||||
@@ -13,6 +16,9 @@ const defaultParams = {
|
||||
repo: '',
|
||||
packageName: '',
|
||||
numOldVersionsToDelete: 0,
|
||||
minVersionsToKeep: 0,
|
||||
ignoreVersions: new RegExp(''),
|
||||
deletePreReleaseVersions: '',
|
||||
token: ''
|
||||
}
|
||||
|
||||
@@ -22,6 +28,9 @@ export class Input {
|
||||
repo: string
|
||||
packageName: string
|
||||
numOldVersionsToDelete: number
|
||||
minVersionsToKeep: number
|
||||
ignoreVersions: RegExp
|
||||
deletePreReleaseVersions: string
|
||||
token: string
|
||||
|
||||
constructor(params?: InputParams) {
|
||||
@@ -32,7 +41,19 @@ export class Input {
|
||||
this.repo = validatedParams.repo
|
||||
this.packageName = validatedParams.packageName
|
||||
this.numOldVersionsToDelete = validatedParams.numOldVersionsToDelete
|
||||
this.minVersionsToKeep = validatedParams.minVersionsToKeep
|
||||
this.ignoreVersions = validatedParams.ignoreVersions
|
||||
this.deletePreReleaseVersions = validatedParams.deletePreReleaseVersions
|
||||
this.token = validatedParams.token
|
||||
|
||||
if (this.minVersionsToKeep > 0) {
|
||||
this.numOldVersionsToDelete = 100 - this.minVersionsToKeep
|
||||
}
|
||||
|
||||
if (this.deletePreReleaseVersions == 'true') {
|
||||
this.numOldVersionsToDelete = 100 - this.minVersionsToKeep
|
||||
this.ignoreVersions = new RegExp('^(0|[1-9]\\d*)((\\.(0|[1-9]\\d*))*)$')
|
||||
}
|
||||
}
|
||||
|
||||
hasOldestVersionQueryInfo(): boolean {
|
||||
@@ -41,6 +62,7 @@ export class Input {
|
||||
this.repo &&
|
||||
this.packageName &&
|
||||
this.numOldVersionsToDelete > 0 &&
|
||||
this.minVersionsToKeep >= 0 &&
|
||||
this.token
|
||||
)
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@ function getActionInput(): Input {
|
||||
repo: getInput('repo') ? getInput('repo') : context.repo.repo,
|
||||
packageName: getInput('package-name'),
|
||||
numOldVersionsToDelete: Number(getInput('num-old-versions-to-delete')),
|
||||
minVersionsToKeep: Number(getInput('min-versions-to-keep')),
|
||||
ignoreVersions: RegExp(getInput('ignore-versions')),
|
||||
deletePreReleaseVersions: getInput(
|
||||
'delete-only-pre-release-versions'
|
||||
).toLowerCase(),
|
||||
token: getInput('token')
|
||||
})
|
||||
}
|
||||
|
||||
@@ -89,9 +89,10 @@ export function getOldestVersions(
|
||||
).pipe(
|
||||
map(result => {
|
||||
if (result.repository.packages.edges.length < 1) {
|
||||
throwError(
|
||||
console.log(
|
||||
`package: ${packageName} not found for owner: ${owner} in repo: ${repo}`
|
||||
)
|
||||
return []
|
||||
}
|
||||
|
||||
const versions = result.repository.packages.edges[0].node.versions.edges
|
||||
|
||||
Reference in New Issue
Block a user