204 Commits

Author SHA1 Message Date
Johanan Idicula
e5bc658cc4 Merge pull request #126 from actions/dependabot/npm_and_yarn/typescript-eslint/parser-6.19.0
build: bump @typescript-eslint/parser from 6.13.1 to 6.19.0
2024-01-15 15:30:21 -05:00
dependabot[bot]
c2e0cba321 build: bump @typescript-eslint/parser from 6.13.1 to 6.19.0
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 6.13.1 to 6.19.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.19.0/packages/parser)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/parser"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-15 20:28:47 +00:00
Johanan Idicula
cbc8c70198 Merge pull request #124 from actions/dependabot/npm_and_yarn/prettier-3.2.2
build: bump prettier from 3.1.0 to 3.2.2
2024-01-15 15:28:19 -05:00
Johanan Idicula
e79c179b5f Merge pull request #123 from actions/dependabot/npm_and_yarn/types/node-20.11.2
build: bump @types/node from 20.10.3 to 20.11.2
2024-01-15 15:27:27 -05:00
dependabot[bot]
5761e031ac build: bump prettier from 3.1.0 to 3.2.2
Bumps [prettier](https://github.com/prettier/prettier) from 3.1.0 to 3.2.2.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.1.0...3.2.2)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-15 16:20:10 +00:00
dependabot[bot]
76ae624236 build: bump @types/node from 20.10.3 to 20.11.2
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.10.3 to 20.11.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-15 16:20:00 +00:00
Johanan Idicula
09a11b91f4 Merge pull request #122 from actions/jidicula/create-dependabot-config
ci: Create dependabot.yml
2024-01-15 11:19:02 -05:00
Johanan Idicula
bb9def2706 ci: Create dependabot.yml 2024-01-15 11:02:08 -05:00
Johanan Idicula
30bbfa2a0b Merge pull request #118 from takost/update-to-node-20
Update action to node20
2024-01-15 10:43:34 -05:00
Tatyana Kostromskaya
55374354a5 Fix license 2023-12-04 13:54:13 +00:00
Tatyana Kostromskaya
4f30122956 Update packages to fix tests 2023-12-04 13:50:32 +00:00
Tatyana Kostromskaya
94b27035e3 . 2023-12-04 13:17:19 +00:00
Tatyana Kostromskaya
f19bddef67 Update action to node20 2023-11-20 13:24:47 +00:00
Anupam
9970186500 Add repository dispatch event to run integration tests (#98) 2023-03-14 21:54:19 +05:30
Anupam
0d39a63126 Add constraint on delete-only-untagged-versions 2023-03-09 15:37:07 +05:30
Anupam
8c3a64de32 Improve delete-only-untagged-versions flag and minor bug fix (#97)
Improve `delete-only-untagged-versions` flag and minor bug fix
2023-03-09 15:31:35 +05:30
Anupam
564c9d0297 Not currently supported in GHES (#95) 2023-03-06 13:11:48 +05:30
Anupam
48cd5a6793 Nit: Change dotcom to GitHub.com in README 2023-03-03 17:02:20 +05:30
Anupam
029d95066b add delete-only-untagged-versions param (#94)
Add a new boolean parameter to action `delete-only-untagged-versions`. When true, only versions that do not have any tags will be deleted.
2023-03-03 16:42:34 +05:30
Anupam
b9ed39f728 Configure baseUrl in octokit initialisation (#91)
Make the action work for GHES by passing `GITHUB_API_URL` environment variable to octokit initialisation.
2023-03-02 19:56:14 +05:30
Nishtha Gupta
ba4d22f251 Merge pull request #86 from actions/nishthaGupta-patch-1
Update version in readme
2023-01-05 17:20:20 +05:30
Nishtha Gupta
22f216e584 Update version in readme 2023-01-05 17:18:58 +05:30
Nishtha Gupta
9a08425079 Merge pull request #85 from actions/dependabot/npm_and_yarn/json5-1.0.2
Bump json5 from 1.0.1 to 1.0.2
2023-01-05 16:25:51 +05:30
dependabot[bot]
ac5977570e Bump json5 from 1.0.1 to 1.0.2
Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-05 10:40:51 +00:00
Anupam
fe2a95a0cb Merge pull request #83 from actions/s-anupam-rest-api
Add support for deleting packages on new GitHub Packages architecture
2023-01-05 16:10:25 +05:30
Anupam
46653ba3cb restrict to RATE_LIMIT with package-version-ids 2023-01-05 10:25:21 +00:00
Anupam
79269eb4bf Update README 2023-01-05 10:08:06 +00:00
Nishtha Gupta
4833470995 Update README.md 2023-01-05 14:05:04 +05:30
Anupam
2de4236b17 Address review coments 2023-01-03 16:35:40 +00:00
Anupam
23073eb4a2 add more UTs, delete ununsed files 2022-12-30 20:03:11 +00:00
Anupam
faf614822d Update test.yml 2022-12-30 19:35:17 +05:30
Anupam
bde81b096d Add packages permission to workflow 2022-12-30 19:30:08 +05:30
Anupam
f1783122af Update test.yml 2022-12-30 19:15:21 +05:30
Nishtha Gupta
404c7849e4 Update rest.dep.yml 2022-12-30 18:49:00 +05:30
Anupam
0b99e5f60d Fix prettier errors 2022-12-30 13:10:17 +00:00
Nishtha Gupta
40030c0eb0 Add mandatory package-type param 2022-12-30 18:36:05 +05:30
Anupam
5e7113f543 update dev dependencies 2022-12-30 12:55:09 +00:00
Anupam
90c8dc6d0b better UT for deletePackageVersions 2022-12-30 08:13:23 +00:00
Anupam
98c1e7eab7 add api UTs 2022-12-30 05:12:10 +00:00
Nishtha Gupta
eaa1f7c20f Update action.yml 2022-12-29 17:43:25 +05:30
Nishtha Gupta
ce1d329288 Update readme: 2022-12-29 15:59:15 +05:30
Nishtha Gupta
9dbafb83da Remove repo param support & logs 2022-12-29 15:51:31 +05:30
Nishtha Gupta
64305dab94 Optimisation 2022-12-29 15:35:31 +05:30
Nishtha Gupta
e95cd87648 Fetch all versions at once 2022-12-29 14:43:48 +05:30
Anupam
7f4037254e add some logs 2022-12-28 18:32:12 +00:00
Anupam
e521d9e753 get versions using rest 2022-12-28 14:43:50 +00:00
Anupam
cc7196aa1d try to fix npm run pack? 2022-12-28 14:39:47 +00:00
Nishtha Gupta
6ce7577c5e Adding logs 2022-12-28 16:56:22 +05:30
Nishtha Gupta
92bd8a3cd0 First commit with delete version API 2022-12-28 16:33:42 +05:30
Anupam
280935cb1a add package-type param to action.yml 2022-12-27 15:11:20 +00:00
Anupam
272ad859dc add package type param 2022-12-27 14:35:56 +00:00
Shyam Grover
c5e64443ea Merge pull request #79 from actions/dependabot/npm_and_yarn/actions/core-1.9.1
Bump @actions/core from 1.6.0 to 1.9.1
2022-11-01 11:53:52 +05:30
Shyam Grover
9b1e76ea45 Update core.dep.yml 2022-11-01 11:51:12 +05:30
Shyam Grover
37b7aca7eb Update core.dep.yml 2022-11-01 11:50:38 +05:30
Shyam Grover
f87b4a0b81 Update README.md 2022-11-01 11:48:29 +05:30
Shyam Grover
6961202f36 Merge pull request #70 from actions/dependabot/npm_and_yarn/minimist-1.2.6
Bump minimist from 1.2.5 to 1.2.6
2022-11-01 11:44:17 +05:30
Naveen Desu
4eab40be13 Merge pull request #82 from gaelgoth/fix_readme_typo
fix typo in readme
2022-09-15 12:02:36 +05:30
gael.gothuey
8701e46f41 fix typo in readme 2022-09-14 22:07:47 +02:00
dependabot[bot]
565ec2459a Bump @actions/core from 1.6.0 to 1.9.1
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.6.0 to 1.9.1.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

---
updated-dependencies:
- dependency-name: "@actions/core"
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-18 19:22:50 +00:00
Tina Heidinger
ec4518c513 Merge pull request #75 from actions/74-add-support-for-deletion-of-container-and-npm-packages
Indicate missing support for GHCR and soon also npm in readme
2022-07-01 11:37:47 +02:00
tinaheidinger
33300d7916 Indicate missing support for GHCR and soon also npm in readme 2022-07-01 11:34:51 +02:00
dependabot[bot]
e048663cdf Bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-26 06:17:25 +00:00
Namrata Jha
0e86ee6891 Update README.md 2022-03-02 13:36:45 +05:30
Namrata Jha
a31a43afa6 Merge pull request #69 from actions/Upgrade-to-node16
Upgrade to node16
2022-03-02 13:28:44 +05:30
Namrata Jha
56849b848a Upgrade to node16 2022-03-02 07:40:19 +00:00
Namrata Jha
000223ef3e Merge pull request #68 from actions/v2-patch-release
change node version for v2 patch release
2022-03-02 12:32:41 +05:30
Namrata Jha
df897cea27 change node version for v2 patch release 2022-03-02 06:11:51 +00:00
Namrata Jha
b77daeff53 Merge pull request #67 from ralfstuckert/main
#66 Type mismatch on variable $packageVersionId and argument packageV…
2022-03-02 11:26:17 +05:30
Ralf Stuckert
7515f7a4f9 #66 Type mismatch on variable $packageVersionId and argument packageVersionId (String! / ID!) 2022-03-01 07:44:01 +01:00
Namrata Jha
3e14cd73d4 Merge pull request #62 from actions/thboop/updatetonode16
Update default runtime to node16
2022-02-16 14:45:08 +05:30
Namrata Jha
5e4787da1c Merge pull request #64 from actions/fix-dependabot-alerts
Fix dependabot alerts
2022-02-16 14:43:28 +05:30
Namrata Jha
355299fa7d fix licensed 2022-02-15 15:21:28 +00:00
Namrata Jha
5263253279 upgrade eslint and fix breaking changes 2022-02-15 13:52:11 +00:00
Namrata Jha
d6bf5f6a97 update node-fetch and ws 2022-02-15 07:10:56 +00:00
Namrata Jha
4afcc8f713 Merge pull request #63 from actions/dependabot/npm_and_yarn/ajv-6.12.6
Bump ajv from 6.10.2 to 6.12.6
2022-02-15 12:23:29 +05:30
dependabot[bot]
1472d90599 Bump ajv from 6.10.2 to 6.12.6
Bumps [ajv](https://github.com/ajv-validator/ajv) from 6.10.2 to 6.12.6.
- [Release notes](https://github.com/ajv-validator/ajv/releases)
- [Commits](https://github.com/ajv-validator/ajv/compare/v6.10.2...v6.12.6)

---
updated-dependencies:
- dependency-name: ajv
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-13 02:52:00 +00:00
Thomas Boop
09f7b84634 Update default runtime to node16
Update default runtime to node16
2022-02-07 13:58:41 -05:00
Namrata Jha
5aa567b6f7 Merge pull request #58 from actions/improve-existing-action
Allow deletion beyond last 100 packages
2021-12-24 15:55:58 +05:30
Namrata Jha
1979f24cbb Merge branch 'improve-existing-action' of https://github.com/actions/delete-package-versions into improve-existing-action 2021-12-24 10:21:12 +00:00
Namrata Jha
6a5e08c48d fix typo 2021-12-24 10:21:02 +00:00
Namrata Jha
f804442fe4 Update README.md 2021-12-24 14:10:14 +05:30
Namrata Jha
5282013b71 Update README.md 2021-12-24 12:35:55 +05:30
Namrata Jha
4d762a4bc3 Merge branch 'improve-existing-action' of https://github.com/actions/delete-package-versions into improve-existing-action 2021-12-23 18:53:34 +00:00
Namrata Jha
aac34a9f33 update tests 2021-12-23 18:53:16 +00:00
Namrata Jha
406ce0281d Update README.md 2021-12-24 00:20:21 +05:30
Namrata Jha
72cc4b27b0 update tests 2021-12-23 17:41:07 +00:00
Namrata Jha
7d188d1776 RATE_LIMIT = 99 2021-12-23 13:02:25 +00:00
Namrata Jha
81676df338 add comments 2021-12-23 13:01:35 +00:00
Namrata Jha
cfbae0ac37 remove excess logs 2021-12-23 09:46:46 +00:00
Namrata Jha
f556b07dce check error 2021-12-23 08:41:06 +00:00
Namrata Jha
8283350471 fix totalCount 2021-12-22 21:39:57 +00:00
Namrata Jha
1a7a0291b8 RATE_LIMIT=100 2021-12-22 19:21:20 +00:00
Namrata Jha
38d4003d57 Merge branch 'improve-existing-action' of https://github.com/actions/delete-package-versions into improve-existing-action 2021-12-22 19:18:26 +00:00
Namrata Jha
bf6c02443a run with RATE_LIMIT=100 2021-12-22 19:09:58 +00:00
Namrata Jha
e9faf3233c check rate limit 2021-12-22 16:17:44 +00:00
Namrata Jha
9ff1e31776 use promise for rate limit 2021-12-22 16:05:18 +00:00
Namrata Jha
0739cce1e8 use tap 2021-12-22 15:49:48 +00:00
Namrata Jha
ef5d9ac398 add logs 2021-12-22 15:45:39 +00:00
Namrata Jha
1369f0ca05 fix ratelimit query 2021-12-22 15:33:41 +00:00
Namrata Jha
372546727d add error handling 2021-12-22 15:30:35 +00:00
Namrata Jha
324039ba0a logs to check rate limit 2021-12-22 15:22:21 +00:00
Namrata Jha
508f6970a5 bypass rate limit 2021-12-22 09:59:18 +00:00
Namrata Jha
e6a9d9c802 set RATE_LIMIT=99 2021-12-21 18:52:10 +00:00
Namrata Jha
21a6c99c5d rate throttling at 100 2021-12-21 18:23:06 +00:00
Namrata Jha
db4d66086a test delete mutation 2021-12-21 18:14:06 +00:00
Namrata Jha
c8087bcc70 fix failed delete mutations 2021-12-21 17:34:02 +00:00
Namrata Jha
75db2288ca intermitent failed delete mutations logs 2021-12-21 16:19:51 +00:00
Namrata Jha
cbfc7d9ca3 Merge branch 'improve-existing-action' of https://github.com/actions/delete-package-versions into improve-existing-action 2021-12-21 09:29:52 +00:00
Namrata Jha
d846be5128 add unit tests 2021-12-21 09:29:12 +00:00
Namrata Jha
15db109d58 Merge branch 'main' into improve-existing-action 2021-12-20 16:19:59 +05:30
Namrata Jha
94d1202726 Update README.md 2021-12-20 16:17:20 +05:30
Namrata Jha
8e78cd925d Update README.md 2021-12-20 16:16:11 +05:30
Namrata Jha
c6b1d83a14 Update README.md 2021-12-20 15:55:01 +05:30
Namrata Jha
b7877514c6 Update README.md 2021-12-20 15:34:15 +05:30
Namrata Jha
370a350353 update ReadME 2021-12-20 10:00:12 +00:00
Namrata Jha
ba58e0e966 update ReadME 2021-12-20 09:45:54 +00:00
Namrata Jha
106b04e076 fix logs 2021-12-20 09:31:36 +00:00
Namrata Jha
04947a51f3 fix logs 2021-12-20 09:21:35 +00:00
Namrata Jha
7d96e1e541 fix delete rate throttling 2021-12-20 09:05:08 +00:00
Namrata Jha
5003595d8e fix delete rate throttling 2021-12-20 08:54:55 +00:00
Namrata Jha
263c5d855a logs to check rate limiting 2021-12-20 08:37:14 +00:00
Namrata Jha
36894fd813 add logs 2021-12-16 08:54:07 +00:00
Namrata Jha
a22ff2a7c5 add delete limit of 100 2021-12-16 07:02:21 +00:00
Namrata Jha
8c24449b56 fix delete all pre release versions 2021-12-14 16:15:58 +00:00
Namrata Jha
0994e6c0d2 fix delete count update condition 2021-12-14 16:06:05 +00:00
Namrata Jha
334f20f7fa fix checks 2021-12-14 15:57:21 +00:00
Namrata Jha
93d3863084 add paging 2021-12-14 15:51:31 +00:00
Namrata Jha
e7ecd94635 change default values 2021-12-14 12:39:22 +00:00
Namrata Jha
c253b9d27a Check input combinations 2021-12-14 12:34:03 +00:00
Namrata Jha
248e3651e3 Check input combinations 2021-12-14 12:22:48 +00:00
Namrata Jha
fd4e8f971f Update README.md 2021-11-25 11:25:32 +05:30
Namrata Jha
fc4c9fe912 Update README.md 2021-11-25 09:33:54 +05:30
Namrata Jha
b19f4fe385 Merge pull request #52 from actions/keep-min-packages
keep min package versions from deletion
2021-11-23 22:35:45 +05:30
Namrata Jha
020712e298 Update README.md 2021-11-23 10:28:51 +00:00
Namrata Jha
6fee3def5e update README.md 2021-11-17 17:27:33 +00:00
Namrata Jha
32b30cfe62 ignore num-versions-to-delete when min-version-to-keep is set 2021-11-17 16:03:40 +00:00
Namrata Jha
b5e80e74e4 fix error for deleting all pre-release versions 2021-11-17 13:15:23 +00:00
Namrata Jha
7f40a506a4 fix error for deleting all pre-release versions 2021-11-17 13:04:11 +00:00
Namrata Jha
8d3af2ed69 fix package not found error 2021-11-17 10:17:38 +00:00
Namrata Jha
2dc6d27141 update input.ts 2021-11-17 08:10:06 +00:00
Namrata Jha
e73aee77b1 allow min pre release versions to be set 2021-11-17 06:52:13 +00:00
Namrata Jha
79a5c93b7a fix typo 2021-11-16 06:35:16 +00:00
Namrata Jha
0de5ea0608 fi delete pre release version by default 2021-11-16 05:34:29 +00:00
Namrata Jha
1ea7a488b4 fix regex to ignore all release versions 2021-11-12 15:42:49 +00:00
Namrata Jha
031ff897b2 fix default regex string 2021-11-12 03:56:38 +00:00
Namrata Jha
7fdaaf4f60 fix default regex string 2021-11-12 03:55:37 +00:00
Namrata Jha
799007d5ff fix default regex 2021-11-12 03:48:27 +00:00
Namrata Jha
4ec126b8cc add ignore versions property 2021-11-12 03:46:59 +00:00
Namrata Jha
bd624e4936 update README.md 2021-11-09 08:26:22 +00:00
Namrata Jha
90bcbbe553 update README.md 2021-11-08 10:09:38 +00:00
Namrata Jha
b5e7ea46fa update delete.ts 2021-11-08 08:19:02 +00:00
Namrata Jha
1f8196ebbc update test 2021-11-08 07:55:55 +00:00
Namrata Jha
398a50a9bf update test 2021-11-08 07:52:02 +00:00
Namrata Jha
18061036ba keep min package versions from deletion 2021-11-08 07:25:16 +00:00
Namrata Jha
0739f428e7 Merge pull request #50 from actions/update-set-value
update jest
2021-10-26 12:39:22 +05:30
Namrata Jha
7ffc8a599c update jest 2021-10-26 06:41:54 +00:00
Namrata Jha
90fbe9a212 Merge pull request #49 from actions/Bumping-up-jest@24.9.0-to-jest@26.1.0
Bump jest from @24.9.0 to @26.1.0
2021-10-26 10:21:22 +05:30
Namrata Jha
5349e7dc4e Revert "Merge branch 'Bumping-up-jest@24.9.0-to-jest@26.1.0' of https://github.com/actions/delete-package-versions into Bumping-up-jest@24.9.0-to-jest@26.1.0"
This reverts commit 417214b728, reversing
changes made to e50524f7ea.
2021-10-25 11:51:47 +00:00
Namrata Jha
417214b728 Merge branch 'Bumping-up-jest@24.9.0-to-jest@26.1.0' of https://github.com/actions/delete-package-versions into Bumping-up-jest@24.9.0-to-jest@26.1.0 2021-10-25 11:41:00 +00:00
Namrata Jha
e50524f7ea update licences 2021-10-25 11:39:04 +00:00
Namrata Jha
bedb90f12a update licences 2021-10-25 11:35:47 +00:00
Namrata Jha
7fa0e1f9f7 fix licenses 2021-10-25 11:18:33 +00:00
Namrata Jha
1b66f3e643 reverting back @types/jest and typescript version 2021-10-25 08:09:27 +00:00
Namrata Jha
81656b7f86 update @types/jest, jest-circus, ts-jest and typescript 2021-10-25 07:34:48 +00:00
Namrata Jha
6badf80095 update jest 2021-10-21 08:37:50 +00:00
Namrata Jha
2767d0ec96 Merge pull request #48 from actions/dependabot/npm_and_yarn/ws-5.2.3
Bump ws from 5.2.2 to 5.2.3
2021-10-19 11:14:02 +05:30
Namrata Jha
4d5c009cd3 Merge pull request #42 from actions/dependabot/npm_and_yarn/hosted-git-info-2.8.9
Bump hosted-git-info from 2.8.5 to 2.8.9
2021-10-18 20:33:47 +05:30
Namrata Jha
f891cc8158 Merge pull request #46 from actions/dependabot/npm_and_yarn/path-parse-1.0.7
Bump path-parse from 1.0.6 to 1.0.7
2021-10-18 20:29:10 +05:30
Namrata Jha
1e1d9c526f Merge pull request #47 from actions/dependabot/npm_and_yarn/tmpl-1.0.5
Bump tmpl from 1.0.4 to 1.0.5
2021-10-18 20:27:55 +05:30
Namrata Jha
e67c4fe012 Merge pull request #38 from actions/dependabot/npm_and_yarn/y18n-4.0.1
Bump y18n from 4.0.0 to 4.0.1
2021-10-18 20:25:49 +05:30
Namrata Jha
bcb7bb9bf4 Merge pull request #41 from actions/dependabot/npm_and_yarn/lodash-4.17.21
Bump lodash from 4.17.19 to 4.17.21
2021-10-18 20:24:47 +05:30
dependabot[bot]
8c6e47eb07 Bump ws from 5.2.2 to 5.2.3
Bumps [ws](https://github.com/websockets/ws) from 5.2.2 to 5.2.3.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/5.2.2...5.2.3)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-18 14:53:46 +00:00
Namrata Jha
46494d7b74 Merge pull request #40 from actions/dependabot/npm_and_yarn/handlebars-4.7.7
Bump handlebars from 4.5.3 to 4.7.7
2021-10-18 20:23:07 +05:30
dependabot[bot]
e9abcd8083 Bump tmpl from 1.0.4 to 1.0.5
Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-21 18:17:13 +00:00
Thomas Boop
a88602f068 Merge pull request #45 from brcrista/brcrista/check-dist
Create check-dist.yml
2021-08-17 13:28:59 -04:00
dependabot[bot]
5bd21282ee Bump path-parse from 1.0.6 to 1.0.7
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-12 02:03:08 +00:00
Brian Cristante
d5a0427147 Fix triggers in licensed.yml 2021-08-10 10:38:50 -04:00
Brian Cristante
e9da08677e Add check-dist.yml 2021-08-10 10:38:18 -04:00
Trent Jones
eac9ac793e Merge pull request #43 from actions/releases/v2
Releases/v2
2021-06-22 15:30:34 -05:00
Trent Jones
f0a2fa531f add trailing newline 2021-06-22 15:28:07 -05:00
Trent Jones
70375d9b94 add codeowners team 2021-06-22 15:27:44 -05:00
Trent Jones
c38a6af07e add codeowners 2021-06-22 15:26:40 -05:00
dependabot[bot]
5b1dcd4637 Bump hosted-git-info from 2.8.5 to 2.8.9
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.5 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.5...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-11 13:10:12 +00:00
dependabot[bot]
a9df53edc6 Bump lodash from 4.17.19 to 4.17.21
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-11 04:50:34 +00:00
dependabot[bot]
b055f56132 Bump handlebars from 4.5.3 to 4.7.7
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.5.3 to 4.7.7.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.5.3...v4.7.7)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-08 19:37:34 +00:00
dependabot[bot]
ace7b23b09 Bump y18n from 4.0.0 to 4.0.1
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-31 15:47:02 +00:00
Andy McKay
71603054af Update README.md
Oops, sorry revert 6c739c3678
2021-03-05 07:48:58 -08:00
Andy McKay
6c739c3678 Mark as unmaintained
Closes #36, would like to see if there any good versions on the Marketplace that we could recommend. If you know of any please let me know and we'll add them in.
2021-03-05 07:45:25 -08:00
Thomas Boop
35f1b743a1 Merge pull request #27 from thboop/main
Add Licensed to help verify production licenses
2020-08-26 11:28:24 -04:00
Thomas Boop
cf7a09a718 Add GitAttributes File to hide generated files in PR 2020-08-26 11:12:04 -04:00
Thomas Boop
8268606cb8 manually verify incorrectly generated licenses 2020-08-11 20:08:17 -04:00
Thomas Boop
2fb7ccbd4f Add Licensed Files and Workflow 2020-08-11 20:07:43 -04:00
Thomas Boop
bffed3fb1f Merge pull request #25 from thboop/thboop/AddThirdPartyLicenses
Add Third Party License Information to Dist Files
2020-08-11 15:22:07 -04:00
Thomas Boop
4efcc40cee Update licenses for @actions npm modules 2020-08-06 19:25:51 -04:00
Thomas Boop
7e49b722e7 Add Third Party License Information 2020-08-06 10:51:31 -04:00
Andy McKay
bace7c436b Merge pull request #23 from actions/update-to-main
Update to main
2020-07-21 08:32:47 -07:00
Andy McKay
0b60a56d0e Update to main 2020-07-21 08:13:33 -07:00
Andy McKay
eb5c637b9d Merge pull request #22 from actions/master
Master
2020-07-21 08:10:15 -07:00
Andy McKay
cc3c3729d7 Merge pull request #11 from actions/dependabot/npm_and_yarn/acorn-5.7.4
Bump acorn from 5.7.3 to 5.7.4
2020-07-21 08:09:10 -07:00
Andy McKay
faa02d25f4 Merge pull request #20 from actions/dependabot/npm_and_yarn/lodash-4.17.19
Bump lodash from 4.17.15 to 4.17.19
2020-07-21 08:09:00 -07:00
dependabot[bot]
a973c4c3a5 Bump lodash from 4.17.15 to 4.17.19
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-19 17:57:30 +00:00
Trent Jones
84f259d626 Merge pull request #16 from ericsciple/users/ericsciple/m262ghes
Use @actions/github to invoke GraphQL for GHES compatibility
2020-05-15 12:29:19 -05:00
eric sciple
f4a606f9ac Use @actions/github@2.2.0 to invoke GraphQL for GHES compatibility 2020-05-13 20:24:25 -04:00
dependabot[bot]
a2a661c47c Bump acorn from 5.7.3 to 5.7.4
Bumps [acorn](https://github.com/acornjs/acorn) from 5.7.3 to 5.7.4.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/5.7.3...5.7.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-04-05 23:22:05 +00:00
28 changed files with 42404 additions and 26944 deletions

View File

@@ -1,6 +1,6 @@
{
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/es6"],
"extends": ["plugin:github/recommended","plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
@@ -17,13 +17,29 @@
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-ignore": "error",
"@typescript-eslint/ban-ts-comment": "error",
"camelcase": "off",
"@typescript-eslint/camelcase": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "class",
"format": ["PascalCase"]
},
{
"selector": "interface",
"format": ["PascalCase"]
},
{
"selector": "typeProperty",
"format": [],
"custom": {
"regex": "^[A-Z][A-Za-z]*$",
"match": false
}
}
],
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/generic-type-naming": ["error", "^[A-Z][A-Za-z]*$"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
@@ -33,7 +49,7 @@
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-object-literal-type-assertion": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
@@ -41,7 +57,7 @@
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-interface": "error",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
@@ -50,7 +66,10 @@
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error",
"no-console": "off"
"no-console": "off",
"import/no-unresolved": "off",
"sort-imports": "off",
"filenames/match-regex": "off"
},
"env": {
"node": true,

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
.licenses/** -diff linguist-generated=true

12
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
version: 2
updates:
# Enable version updates for npm
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
time: "06:00"
timezone: "UTC"
open-pull-requests-limit: 3
commit-message:
prefix: "build: "

51
.github/workflows/check-dist.yml vendored Normal file
View File

@@ -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 20.x
uses: actions/setup-node@v1
with:
node-version: 20.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/

16
.github/workflows/integration-tests.yml vendored Normal file
View File

@@ -0,0 +1,16 @@
name: Repository dispatch event for Integration Tests
on:
push:
branches: [ "main" ]
jobs:
repository_dispatch_event:
runs-on: ubuntu-latest
steps:
- name: Repository Dispatch Event
uses: peter-evans/repository-dispatch@26b39ed245ab8f31526069329e112ab2fb224588
with:
token: ${{ secrets.ITS_PAT }}
repository: ${{ secrets.ITS_REPO }}
event-type: delete-package-versions-its

24
.github/workflows/licensed.yml vendored Normal file
View File

@@ -0,0 +1,24 @@
name: Licensed
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
name: Check licenses
steps:
- uses: actions/checkout@v2
- run: npm ci
- name: Install licensed
run: |
cd $RUNNER_TEMP
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

View File

@@ -4,9 +4,12 @@ on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- master
- main
- 'releases/*'
permissions:
packages: write
jobs:
package: # make sure build/ci work properly
@@ -15,6 +18,9 @@ jobs:
steps:
- uses: actions/checkout@v2
name: Checkout Delete Package Versions Repo
- uses: actions/setup-node@v3
with:
node-version: 20
- run: npm install
name: NPM Install
- run: npm run pack
@@ -26,8 +32,12 @@ jobs:
steps:
- uses: actions/checkout@v2
name: Checkout Delete Package Versions Repo
- uses: actions/setup-node@v3
with:
node-version: 20
- uses: ./
name: Smoke Test Delete Package Versions Action
with:
package-name: 'com.github.actions.test-package'
num-old-versions-to-delete: 0
package-name: 'action-ci-test-package'
package-type: 'npm'
num-old-versions-to-delete: 0

14
.licensed.yml Normal file
View File

@@ -0,0 +1,14 @@
sources:
npm: true
allowed:
- apache-2.0
- bsd-2-clause
- bsd-3-clause
- isc
- mit
- cc0-1.0
- unlicense
reviewed:
npm:

20
.licenses/npm/@actions/core.dep.yml generated Normal file
View File

@@ -0,0 +1,20 @@
---
name: "@actions/core"
version: 1.10.1
type: npm
summary: Actions core lib
homepage: https://github.com/actions/toolkit/tree/main/packages/core
license: mit
licenses:
- sources: LICENSE.md
text: |-
The MIT License (MIT)
Copyright 2019 GitHub
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: []

20
.licenses/npm/@actions/github.dep.yml generated Normal file
View File

@@ -0,0 +1,20 @@
---
name: "@actions/github"
version: 6.0.0
type: npm
summary: Actions github lib
homepage: https://github.com/actions/toolkit/tree/main/packages/github
license: mit
licenses:
- sources: LICENSE.md
text: |-
The MIT License (MIT)
Copyright 2019 GitHub
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: []

35
.licenses/npm/@octokit/rest.dep.yml generated Normal file
View File

@@ -0,0 +1,35 @@
---
name: "@octokit/rest"
version: 20.0.2
type: npm
summary: GitHub REST API client for Node.js
homepage:
license: mit
licenses:
- sources: LICENSE
text: |
The MIT License
Copyright (c) 2012 Cloud9 IDE, Inc. (Mike de Boer)
Copyright (c) 2017-2018 Octokit contributors
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.
- sources: README.md
text: "[MIT](LICENSE)"
notices: []

148
.licenses/npm/rxjs.dep.yml generated Normal file
View File

@@ -0,0 +1,148 @@
---
name: rxjs
version: 7.8.1
type: npm
summary: Reactive Extensions for modern JavaScript
homepage: https://rxjs.dev
license: apache-2.0
licenses:
- sources: LICENSE.txt
text: " Apache License\n Version
2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS
AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n
\ \"License\" shall mean the terms and conditions for use, reproduction,\n and
distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\"
shall mean the copyright owner or entity authorized by\n the copyright owner
that is granting the License.\n\n \"Legal Entity\" shall mean the union of
the acting entity and all\n other entities that control, are controlled by,
or are under common\n control with that entity. For the purposes of this definition,\n
\ \"control\" means (i) the power, direct or indirect, to cause the\n direction
or management of such entity, whether by contract or\n otherwise, or (ii) ownership
of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial
ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual
or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\"
form shall mean the preferred form for making modifications,\n including but
not limited to software source code, documentation\n source, and configuration
files.\n\n \"Object\" form shall mean any form resulting from mechanical\n
\ transformation or translation of a Source form, including but\n not limited
to compiled object code, generated documentation,\n and conversions to other
media types.\n\n \"Work\" shall mean the work of authorship, whether in Source
or\n Object form, made available under the License, as indicated by a\n copyright
notice that is included in or attached to the work\n (an example is provided
in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether
in Source or Object\n form, that is based on (or derived from) the Work and
for which the\n editorial revisions, annotations, elaborations, or other modifications\n
\ represent, as a whole, an original work of authorship. For the purposes\n
\ of this License, Derivative Works shall not include works that remain\n separable
from, or merely link (or bind by name) to the interfaces of,\n the Work and
Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship,
including\n the original version of the Work and any modifications or additions\n
\ to that Work or Derivative Works thereof, that is intentionally\n submitted
to Licensor for inclusion in the Work by the copyright owner\n or by an individual
or Legal Entity authorized to submit on behalf of\n the copyright owner. For
the purposes of this definition, \"submitted\"\n means any form of electronic,
verbal, or written communication sent\n to the Licensor or its representatives,
including but not limited to\n communication on electronic mailing lists, source
code control systems,\n and issue tracking systems that are managed by, or
on behalf of, the\n Licensor for the purpose of discussing and improving the
Work, but\n excluding communication that is conspicuously marked or otherwise\n
\ designated in writing by the copyright owner as \"Not a Contribution.\"\n\n
\ \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on
behalf of whom a Contribution has been received by Licensor and\n subsequently
incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the
terms and conditions of\n this License, each Contributor hereby grants to You
a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n
\ copyright license to reproduce, prepare Derivative Works of,\n publicly
display, publicly perform, sublicense, and distribute the\n Work and such Derivative
Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the
terms and conditions of\n this License, each Contributor hereby grants to You
a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n
\ (except as stated in this section) patent license to make, have made,\n use,
offer to sell, sell, import, and otherwise transfer the Work,\n where such
license applies only to those patent claims licensable\n by such Contributor
that are necessarily infringed by their\n Contribution(s) alone or by combination
of their Contribution(s)\n with the Work to which such Contribution(s) was
submitted. If You\n institute patent litigation against any entity (including
a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or
a Contribution incorporated within the Work constitutes direct\n or contributory
patent infringement, then any patent licenses\n granted to You under this License
for that Work shall terminate\n as of the date such litigation is filed.\n\n
4. Redistribution. You may reproduce and distribute copies of the\n Work or
Derivative Works thereof in any medium, with or without\n modifications, and
in Source or Object form, provided that You\n meet the following conditions:\n\n
\ (a) You must give any other recipients of the Work or\n Derivative
Works a copy of this License; and\n\n (b) You must cause any modified files
to carry prominent notices\n stating that You changed the files; and\n\n
\ (c) You must retain, in the Source form of any Derivative Works\n that
You distribute, all copyright, patent, trademark, and\n attribution notices
from the Source form of the Work,\n excluding those notices that do not
pertain to any part of\n the Derivative Works; and\n\n (d) If the Work
includes a \"NOTICE\" text file as part of its\n distribution, then any
Derivative Works that You distribute must\n include a readable copy of
the attribution notices contained\n within such NOTICE file, excluding
those notices that do not\n pertain to any part of the Derivative Works,
in at least one\n of the following places: within a NOTICE text file distributed\n
\ as part of the Derivative Works; within the Source form or\n documentation,
if provided along with the Derivative Works; or,\n within a display generated
by the Derivative Works, if and\n wherever such third-party notices normally
appear. The contents\n of the NOTICE file are for informational purposes
only and\n do not modify the License. You may add Your own attribution\n
\ notices within Derivative Works that You distribute, alongside\n or
as an addendum to the NOTICE text from the Work, provided\n that such additional
attribution notices cannot be construed\n as modifying the License.\n\n
\ You may add Your own copyright statement to Your modifications and\n may
provide additional or different license terms and conditions\n for use, reproduction,
or distribution of Your modifications, or\n for any such Derivative Works as
a whole, provided Your use,\n reproduction, and distribution of the Work otherwise
complies with\n the conditions stated in this License.\n\n 5. Submission of
Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally
submitted for inclusion in the Work\n by You to the Licensor shall be under
the terms and conditions of\n this License, without any additional terms or
conditions.\n Notwithstanding the above, nothing herein shall supersede or
modify\n the terms of any separate license agreement you may have executed\n
\ with Licensor regarding such Contributions.\n\n 6. Trademarks. This License
does not grant permission to use the trade\n names, trademarks, service marks,
or product names of the Licensor,\n except as required for reasonable and customary
use in describing the\n origin of the Work and reproducing the content of the
NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law
or\n agreed to in writing, Licensor provides the Work (and each\n Contributor
provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation,
any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY,
or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining
the\n appropriateness of using or redistributing the Work and assume any\n
\ risks associated with Your exercise of permissions under this License.\n\n
8. Limitation of Liability. In no event and under no legal theory,\n whether
in tort (including negligence), contract, or otherwise,\n unless required by
applicable law (such as deliberate and grossly\n negligent acts) or agreed
to in writing, shall any Contributor be\n liable to You for damages, including
any direct, indirect, special,\n incidental, or consequential damages of any
character arising as a\n result of this License or out of the use or inability
to use the\n Work (including but not limited to damages for loss of goodwill,\n
\ work stoppage, computer failure or malfunction, or any and all\n other
commercial damages or losses), even if such Contributor\n has been advised
of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability.
While redistributing\n the Work or Derivative Works thereof, You may choose
to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n
\ or other liability obligations and/or rights consistent with this\n License.
However, in accepting such obligations, You may act only\n on Your own behalf
and on Your sole responsibility, not on behalf\n of any other Contributor,
and only if You agree to indemnify,\n defend, and hold each Contributor harmless
for any liability\n incurred by, or claims asserted against, such Contributor
by reason\n of your accepting any such warranty or additional liability.\n\n
END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your
work.\n\n To apply the Apache License to your work, attach the following\n
\ boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced
with your own identifying information. (Don't include\n the brackets!) The
text should be enclosed in the appropriate\n comment syntax for the file format.
We also recommend that a\n file or class name and description of purpose be
included on the\n same \"printed page\" as the copyright notice for easier\n
\ identification within third-party archives.\n\n Copyright (c) 2015-2018 Google,
Inc., Netflix, Inc., Microsoft Corp. and contributors\n\n Licensed under the Apache
License, Version 2.0 (the \"License\");\n you may not use this file except in
compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n
Unless required by applicable law or agreed to in writing, software\n distributed
under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific
language governing permissions and\n limitations under the License.\n \n"
notices: []

1
CODEOWNERS Normal file
View File

@@ -0,0 +1 @@
* @actions/packages

443
README.md
View File

@@ -1,207 +1,414 @@
# Delete Package Versions
This action deletes versions of a package from [GitHub Packages](https://github.com/features/packages).
This action deletes versions of a package from [GitHub Packages](https://github.com/features/packages). This action will only delete a maximum of 100 versions in one run.
### What It Can Do
* 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 from a repo having access to package
* Delete version(s) of a package that is hosted from a repo not having access to package
* Delete a single version
* Delete multiple versions
* Delete specific version(s)
* 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
* Delete specific version(s)
# Usage
```yaml
- uses: actions/delete-package-versions@v1
- uses: actions/delete-package-versions@v4
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:
# Owner of the repo hosting the package.
# Owner of 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.
# Required if deleting a version from a package hosted in a different org 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. Can be one of container, maven, npm, nuget, or rubygems.
# Required
package-type:
# The number of old versions to delete starting from the oldest version.
# Defaults to 1.
num-old-versions-to-delete:
# The number of latest versions to keep.
# This cannot be specified with `num-old-versions-to-delete`. By default, `min-versions-to-keep` takes precedence over `num-old-versions-to-delete`.
# When set to 0, all deletable versions will be deleted.
# When set greater than 0, all deletable package versions except the specified number will be deleted.
min-versions-to-keep:
# The package versions to exclude from deletion.
# Takes regex for the version name as input.
# By default nothing is ignored. This is ignored when `delete-only-pre-release-versions` is true
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.
# Cannot be used with `num-old-versions-to-delete` and `ignore-versions`.
delete-only-pre-release-versions:
# If true it will delete only the untagged versions in case of container package.
# Does not work for other package types and will be ignored.
# The number of untagged versions to keep can be set by using `min-versions-to-keep` value with this.
# When `min-versions-to-keep` is 0, all untagged versions get deleted.
# Defaults to false.
# Cannot be used with `num-old-versions-to-delete`.
delete-only-untagged-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.
# Required if the repo running the workflow does not have access to delete the package.
# For rubygems and maven package, repo has access if package is hosted in the same repo as the workflow.
# For container, npm and nuget package, repo has access if assigned **Admin** role under Package Settings > Manage Actions Access.
# 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:
```
# Valid Input Combinations
`owner`, `package-name`, `package-type` and `token` can be used with the following combinations in a workflow -
- `num-old-versions-to-delete`
- `min-versions-to-keep`
- `delete-only-pre-release-versions`
- `ignore-versions`
- `num-old-versions-to-delete` + `ignore-versions`
- `min-versions-to-keep` + `ignore-versions`
- `min-versions-to-keep` + `delete-only-pre-release-versions`
- `delete-only-untagged-versions`
- `min-versions-to-keep` + `delete-only-untagged-versions`
# 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 Package Versions](#delete-package-versions)
- [What It Can Do](#what-it-can-do)
- [Usage](#usage)
- [Valid Input Combinations](#valid-input-combinations)
- [Scenarios](#scenarios)
- [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 untagged container versions except y latest untagged versions](#delete-all-untagged-container-versions-except-y-latest-untagged-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)
- [License](#license)
### Delete a specific version of a package hosted in the same repo as the workflow
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.
### Delete all pre-release versions except y latest pre-release package versions
Package version ids can be retrieved via the [GitHub GraphQL API][api]
To delete all pre release versions except y latest pre-release package versions, the __package-name__, __min-versions-to-keep__ and __delete-only-pre-release-versions__ inputs are required.
__Example__
__Example__
```yaml
- uses: actions/delete-package-versions@v1
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
```
Delete all pre-release package versions except latest 10
<br>
```yaml
- uses: actions/delete-package-versions@v4
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 from a repo not having access to package, the __owner__, __package-name__, __token__, __min-versions-to-keep__ and __delete-only-pre-release-versions__ inputs are required.
### 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 from a repo not having access to package
Package version ids can be retrieved via the [GitHub GraphQL API][api].
```yaml
- uses: actions/delete-package-versions@v4
with:
owner: 'github'
package-name: 'test-package'
package-type: 'npm'
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 untagged container versions except y latest untagged versions
```yaml
- uses: actions/delete-package-versions@v1
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
token: ${{ secrets.GITHUB_PAT }}
```
To delete all untagged versions of a container package except y latest untagged versions, the __package-name__, __package-type__, __min-versions-to-keep__ and __delete-only-untagged-versions__ inputs are required. __package-type__ must be container for this scenario.
<br>
__Example__
### Delete multiple specific versions of a package hosted in the same repo as the workflow
Delete all untagged versions except latest 10
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@v4
with:
package-name: 'test-package'
package-type: 'container'
min-versions-to-keep: 10
delete-only-untagged-versions: 'true'
```
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].
<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, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw'
```
To delete all except y latest versions while ignoring particular package versions, the __package-name__, __min-versions-to-keep__ and __ignore-versions__ inputs are required.
<br>
__Example__
### Delete multiple specific versions of a package hosted in a different repo than the workflow
Delete all except latest 3 package versions excluding major versions as per semver
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.
```yaml
- uses: actions/delete-package-versions@v4
with:
package-name: 'test-package'
package-type: 'npm'
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 from a repo not having access to package, the __owner__, __package-name__, __token__, __min-versions-to-keep__ and __ignore-versions__ inputs are required.
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__.
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-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw'
token: ${{ secrets.GITHUB_PAT }}
```
Delete all except latest 3 package versions excluding major versions as per semver from a repo not having access to package
<br>
```yaml
- uses: actions/delete-package-versions@v4
with:
owner: 'github'
package-name: 'test-package'
package-type: 'npm'
token: ${{ secrets.GITHUB_PAT }}
min-versions-to-keep: 3
ignore-versions: '^(0|[1-9]\\d*)\\.0\\.0$'
```
### Delete oldest version of a package hosted in the same repo as the workflow
<br>
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.
### Delete oldest x number of versions while ignoring particular package versions
__Example__
To delete oldest x number of versions while ignoring all the major package versions, the __package-name__, __num-oldest-versions-to-delete__ and __ignore-versions__ inputs are required.
```yaml
- uses: actions/delete-package-versions@v1
with:
package-name: 'test-package'
```
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.
<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
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@v4
with:
package-name: 'test-package'
package-type: 'npm'
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__.
To delete oldest x number of versions while ignoring all the major package versions from a repo not having access to package, the __owner__, __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:
owner: 'github'
repo: 'packages'
package-name: 'test-package'
token: ${{ secrets.GITHUB_PAT }}
```
__Example__
<br>
Delete 3 oldest versions excluding major versions as per semver from a repo not having access to package
### Delete oldest x number of versions of a package hosted in the same repo as the workflow
```yaml
- uses: actions/delete-package-versions@v4
with:
owner: 'github'
package-name: 'test-package'
package-type: 'npm'
token: ${{ secrets.PAT }}
num-old-versions-to-delete: 3
ignore-versions: '^(0|[1-9]\\d*)\\.0\\.0$'
```
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.
<br>
__Example__
### Delete all except y latest versions of a package
Delete the oldest 3 version of a package hosted in the same repo as the workflow
To delete all except y latest versions of a package hosted, the __package-name__ and __min-versions-to-keep__ inputs are required.
```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
### Delete oldest x number of versions of a package hosted in a different repo than the workflow
```yaml
- uses: actions/delete-package-versions@v4
with:
package-name: 'test-package'
package-type: 'npm'
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.
To delete all except y latest versions of a package hosted from a repo not having access to package, 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__.
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 the oldest 3 version of a package hosted in a different repo than the one executing the workflow
Delete all except latest 2 versions of a package hosted from a repo not having access to package
```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 }}
```
```yaml
- uses: actions/delete-package-versions@v4
with:
owner: 'github'
package-name: 'test-package'
package-type: 'npm'
token: ${{ secrets.PAT }}
min-versions-to-keep: 2
```
<br>
### Delete oldest x number of versions of a package
To delete the oldest x number of versions of a package hosted, the __package-name__, and __num-old-versions-to-delete__ inputs are required.
__Example__
Delete the oldest 3 version of a package hosted
```yaml
- uses: actions/delete-package-versions@v4
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 from a repo not having access to package, 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__.
__Example__
Delete the oldest 3 version of a package hosted from a repo not having access to package
```yaml
- uses: actions/delete-package-versions@v4
with:
owner: 'github'
package-name: 'test-package'
package-type: 'npm'
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, the __package-name__ input is required.
__Example__
```yaml
- uses: actions/delete-package-versions@v4
with:
package-name: 'test-package'
package-type: 'npm'
```
To delete the oldest version of a package that is hosted from a repo not having access to package, the __owner__, __package-name__, __token__ inputs are required.
__Example__
```yaml
- uses: actions/delete-package-versions@v4
with:
owner: 'github'
package-name: 'test-package'
package-type: 'npm'
token: ${{ secrets.PAT }}
```
<br>
### Delete a specific version of a package
To delete a specific version of a package that is hosted, the __package-version-ids__ input is required.
Package version ids can be retrieved via the [GitHub REST API][api]
__Example__
```yaml
- uses: actions/delete-package-versions@v4
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
package-name: 'test-package'
package-type: 'npm'
```
To delete a specific version of a package that is hosted from a repo not having access to package, the __package-version-ids__ and __token__ inputs are required.
Package version ids can be retrieved via the [GitHub REST API][api]
__Example__
```yaml
- uses: actions/delete-package-versions@v4
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3'
package-name: 'test-package'
package-type: 'npm'
token: ${{ secrets.PAT }}
```
<br>
### Delete multiple specific versions of a package
To delete multiple specific versions of a package that is hosted, 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 REST API][api].
__Example__
```yaml
- uses: actions/delete-package-versions@v4
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 from a repo not having access to package, 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 REST API][api].
__Example__
```yaml
- uses: actions/delete-package-versions@v4
with:
package-version-ids: 'MDE0OlBhY2thZ2VWZXJzaW9uOTcyMDY3, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzQ5, MDE0OlBhY2thZ2VWZXJzaW9uOTcyMzUw'
package-name: 'test-package'
package-type: 'npm'
token: ${{ secrets.PAT }}
```
# License
The scripts and documentation in this project are released under the [MIT License](https://github.com/actions/delete-package-versions/blob/master/LICENSE)
The scripts and documentation in this project are released under the [MIT License](https://github.com/actions/delete-package-versions/blob/main/LICENSE)
[api]: https://developer.github.com/v4/previews/#github-packages
[api]: https://docs.github.com/en/rest/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

View File

@@ -1,43 +1,347 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import {rest} from 'msw'
import {setupServer} from 'msw/node'
import {Input, InputParams} from '../src/input'
import {deleteVersions, getVersionIds} from '../src/delete'
import {deleteVersions, finalIds, RATE_LIMIT} from '../src/delete'
import {getMockedVersionsResponse} from './version/rest.mock'
import {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types'
describe.skip('index tests -- call graphql', () => {
it('getVersionIds test -- get oldest version', done => {
const numVersions = 1
type GetVersionsResponseData =
RestEndpointMethodTypes['packages']['getAllPackageVersionsForPackageOwnedByUser']['response']['data']
getVersionIds(getInput({numOldVersionsToDelete: numVersions})).subscribe(
ids => {
expect(ids.length).toBe(numVersions)
done()
}
)
describe('index tests -- call rest', () => {
let server = setupServer()
beforeEach(() => {
server = setupServer()
server.listen()
})
it('getVersionIds test -- get oldest 3 versions', done => {
const numVersions = 3
getVersionIds(getInput({numOldVersionsToDelete: numVersions})).subscribe(
ids => {
expect(ids.length).toBe(numVersions)
done()
}
)
afterEach(() => {
server.close()
})
it('getVersionIds test -- supplied package version id', done => {
const suppliedIds = [
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB',
'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC'
]
getVersionIds(getInput({packageVersionIds: suppliedIds})).subscribe(ids => {
expect(ids).toBe(suppliedIds)
it('finalIds test - supplied package version id', done => {
const suppliedIds = ['123', '456', '789']
finalIds(getInput({packageVersionIds: suppliedIds})).subscribe(ids => {
expect(ids).toStrictEqual(suppliedIds)
done()
})
})
it('deleteVersions test -- missing token', done => {
it('finalIDs test - success', done => {
const numVersions = 10
let apiCalled = 0
const versions = getMockedVersionsResponse(numVersions)
server.use(
rest.get(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions',
(req, res, ctx) => {
apiCalled++
return res(ctx.status(200), ctx.json(versions))
}
)
)
finalIds(getInput()).subscribe(ids => {
expect(apiCalled).toBe(1)
expect(ids.length).toBe(numVersions)
for (let i = 0; i < numVersions; i++) {
expect(ids[i]).toBe(versions[i].id.toString())
}
done()
})
})
it('finalIDs test - success - GHES', done => {
process.env.GITHUB_API_URL = 'https://github.someghesinstance.com/api/v3'
const numVersions = 10
let apiCalled = 0
const versions = getMockedVersionsResponse(numVersions)
server.use(
rest.get(
'https://github.someghesinstance.com/api/v3/users/test-owner/packages/npm/test-package/versions',
(req, res, ctx) => {
apiCalled++
return res(ctx.status(200), ctx.json(versions))
}
)
)
finalIds(getInput()).subscribe(ids => {
expect(apiCalled).toBe(1)
expect(ids.length).toBe(numVersions)
for (let i = 0; i < numVersions; i++) {
expect(ids[i]).toBe(versions[i].id.toString())
}
delete process.env.GITHUB_API_URL
done()
})
})
it('finalIDs test - success - pagination', done => {
const numVersions = RATE_LIMIT * 2
let apiCalled = 0
const versions = getMockedVersionsResponse(numVersions)
const firstPage = versions.slice(0, RATE_LIMIT)
const secondPage = versions.slice(RATE_LIMIT)
server.use(
rest.get(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions',
(req, res, ctx) => {
apiCalled++
const page = req.url.searchParams.get('page')
if (page === '1') {
return res(ctx.status(200), ctx.json(firstPage))
} else if (page === '2') {
return res(ctx.status(200), ctx.json(secondPage))
} else {
return res(ctx.status(200), ctx.json([]))
}
}
)
)
finalIds(getInput()).subscribe(ids => {
expect(apiCalled).toBe(3) // 2 full pages + 1 empty page
// never returns more than RATE_LIMIT versions
expect(ids.length).toBe(RATE_LIMIT)
for (let i = 0; i < RATE_LIMIT; i++) {
expect(ids[i]).toBe(versions[i].id.toString())
}
done()
})
})
it('finalIDs test - success - sorting accross pages', done => {
const numVersions = RATE_LIMIT * 2
let apiCalled = 0
// versions is in ascending order of created_at
const versions = getMockedVersionsResponse(numVersions)
// return newer versions on first page to test sorting
const firstPage = versions.slice(RATE_LIMIT).reverse()
const secondPage = versions.slice(0, RATE_LIMIT).reverse()
server.use(
rest.get(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions',
(req, res, ctx) => {
apiCalled++
const page = req.url.searchParams.get('page')
if (page === '1') {
return res(ctx.status(200), ctx.json(firstPage))
} else if (page === '2') {
return res(ctx.status(200), ctx.json(secondPage))
} else {
return res(ctx.status(200), ctx.json([]))
}
}
)
)
finalIds(getInput()).subscribe(ids => {
expect(apiCalled).toBe(3) // 2 full pages + 1 empty page
expect(ids.length).toBe(RATE_LIMIT)
for (let i = 0; i < RATE_LIMIT; i++) {
expect(ids[i]).toBe(versions[i].id.toString())
}
done()
})
})
it('finalIds test - do not delete more than numOldVersionsToDelete', done => {
const numVersions = 50
let apiCalled = 0
const versions = getMockedVersionsResponse(numVersions)
server.use(
rest.get(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions',
(req, res, ctx) => {
apiCalled++
return res(ctx.status(200), ctx.json(versions))
}
)
)
const numOldVersionsToDelete = 10
finalIds(getInput({numOldVersionsToDelete})).subscribe(ids => {
expect(apiCalled).toBe(1)
expect(ids.length).toBe(numOldVersionsToDelete)
for (let i = 0; i < numOldVersionsToDelete; i++) {
expect(ids[i]).toBe(versions[i].id.toString())
}
done()
})
})
it('finalIds test - keep minVersionsToKeep', done => {
const numVersions = 50
let apiCalled = 0
const versions = getMockedVersionsResponse(numVersions)
server.use(
rest.get(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions',
(req, res, ctx) => {
apiCalled++
return res(ctx.status(200), ctx.json(versions))
}
)
)
const minVersionsToKeep = 10
finalIds(getInput({minVersionsToKeep})).subscribe(ids => {
expect(apiCalled).toBe(1)
expect(ids.length).toBe(numVersions - minVersionsToKeep)
for (let i = 0; i < numVersions - minVersionsToKeep; i++) {
expect(ids[i]).toBe(versions[i].id.toString())
}
done()
})
})
it('finalIds test - delete only prerelease versions with minVersionsToKeep', done => {
const numVersions = 50
let apiCalled = 0
const versions = getMockedVersionsResponse(numVersions)
// make half versions prerelease
for (let i = 0; i < numVersions; i++) {
if (i % 2 === 0) {
versions[i].name += '-alpha'
}
}
server.use(
rest.get(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions',
(req, res, ctx) => {
apiCalled++
return res(ctx.status(200), ctx.json(versions))
}
)
)
const toDelete = numVersions / 2 - 10
finalIds(
getInput({
ignoreVersions: RegExp('^(0|[1-9]\\d*)((\\.(0|[1-9]\\d*))*)$'),
minVersionsToKeep: 10
})
).subscribe(ids => {
expect(apiCalled).toBe(1)
expect(ids.length).toBe(toDelete)
for (let i = 0; i < toDelete; i++) {
expect(ids[i]).toBe(versions[i * 2].id.toString())
}
done()
})
})
it('finalIds test - delete only untagged versions with minVersionsToKeep', done => {
const numVersions = 50
const numTaggedVersions = 20
const numUntaggedVersions = numVersions - numTaggedVersions
const taggedVersions = getMockedVersionsResponse(
numTaggedVersions,
0,
'container',
true
)
const untaggedVersions = getMockedVersionsResponse(
numUntaggedVersions,
numTaggedVersions,
'container',
false
)
const versions = taggedVersions.concat(untaggedVersions)
let apiCalled = 0
server.use(
rest.get(
'https://api.github.com/users/test-owner/packages/container/test-package/versions',
(req, res, ctx) => {
apiCalled++
return res(ctx.status(200), ctx.json(versions))
}
)
)
finalIds(
getInput({
minVersionsToKeep: 10,
deleteUntaggedVersions: 'true',
packageType: 'container'
})
).subscribe(ids => {
expect(apiCalled).toBe(1)
expect(ids.length).toBe(numUntaggedVersions - 10)
for (let i = 0; i < numUntaggedVersions - 10; i++) {
expect(ids[i]).toBe(untaggedVersions[i].id.toString())
}
done()
})
})
it('finalIds test - no versions deleted if API error even once', done => {
const numVersions = RATE_LIMIT * 2
let apiCalled = 0
const versions = getMockedVersionsResponse(numVersions)
const firstPage = versions.slice(0, RATE_LIMIT)
const secondPage = versions.slice(RATE_LIMIT)
server.use(
rest.get(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions',
(req, res, ctx) => {
apiCalled++
const page = req.url.searchParams.get('page')
if (page === '1') {
return res(ctx.status(200), ctx.json(firstPage))
} else if (page === '2') {
return res(ctx.status(500), ctx.json([]))
} else {
return res(ctx.status(200), ctx.json([]))
}
}
)
)
finalIds(getInput()).subscribe(
() => {
done.fail('should not complete')
},
err => {
expect(apiCalled).toBe(2) // 1 full page + 1 error page
expect(err).toBeTruthy()
expect(err).toContain('get versions API failed.')
done()
}
)
})
it('deleteVersions test - missing token', done => {
deleteVersions(getInput({token: ''})).subscribe({
error: err => {
expect(err).toBeTruthy()
@@ -47,7 +351,7 @@ describe.skip('index tests -- call graphql', () => {
})
})
it('deleteVersions test -- missing packageName', done => {
it('deleteVersions test - missing packageName', done => {
deleteVersions(getInput({packageName: ''})).subscribe({
error: err => {
expect(err).toBeTruthy()
@@ -57,32 +361,123 @@ describe.skip('index tests -- call graphql', () => {
})
})
it('deleteVersions test -- delete oldest version', done => {
deleteVersions(getInput({numOldVersionsToDelete: 1})).subscribe(
isSuccess => {
expect(isSuccess).toBe(true)
it('deleteVersions test - missing packageType', done => {
deleteVersions(getInput({packageType: ''})).subscribe({
error: err => {
expect(err).toBeTruthy()
done()
}
)
},
complete: async () => done.fail('no error thrown')
})
})
it('deleteVersions test -- delete 3 oldest versions', done => {
deleteVersions(getInput({numOldVersionsToDelete: 3})).subscribe(
isSuccess => {
expect(isSuccess).toBe(true)
done()
}
it('deleteVersions test - zero numOldVersionsToDelete', done => {
deleteVersions(getInput({numOldVersionsToDelete: 0})).subscribe(result => {
expect(result).toBe(true)
done()
})
})
it('deleteVersions test - success complete flow', done => {
const numVersions = 10
let getApiCalled = 0
let deleteApiCalled = 0
const versions = getMockedVersionsResponse(numVersions)
const versionsDeleted: string[] = []
server.use(
rest.get(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions',
(req, res, ctx) => {
getApiCalled++
return res(ctx.status(200), ctx.json(versions))
}
)
)
server.use(
rest.delete(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions/:versionId',
(req, res, ctx) => {
deleteApiCalled++
versionsDeleted.push(req.params.versionId as string)
return res(ctx.status(204))
}
)
)
deleteVersions(getInput())
.subscribe(result => {
expect(result).toBe(true)
})
.add(() => {
expect(getApiCalled).toBe(1)
expect(deleteApiCalled).toBe(numVersions)
for (let i = 0; i < numVersions; i++) {
expect(versionsDeleted[i]).toBe(versions[i].id.toString())
}
done()
})
})
it('deleteVersions test - success complete flow - GHES', done => {
process.env.GITHUB_API_URL = 'https://github.someghesinstance.com/api/v3'
const numVersions = 10
let getApiCalled = 0
let deleteApiCalled = 0
const versions = getMockedVersionsResponse(numVersions)
const versionsDeleted: string[] = []
server.use(
rest.get(
'https://github.someghesinstance.com/api/v3/users/test-owner/packages/npm/test-package/versions',
(req, res, ctx) => {
getApiCalled++
return res(ctx.status(200), ctx.json(versions))
}
)
)
server.use(
rest.delete(
'https://github.someghesinstance.com/api/v3/users/test-owner/packages/npm/test-package/versions/:versionId',
(req, res, ctx) => {
deleteApiCalled++
versionsDeleted.push(req.params.versionId as string)
return res(ctx.status(204))
}
)
)
deleteVersions(getInput())
.subscribe(result => {
expect(result).toBe(true)
})
.add(() => {
expect(getApiCalled).toBe(1)
expect(deleteApiCalled).toBe(numVersions)
for (let i = 0; i < numVersions; i++) {
expect(versionsDeleted[i]).toBe(versions[i].id.toString())
}
delete process.env.GITHUB_API_URL
done()
})
})
})
const defaultInput: InputParams = {
packageVersionIds: [],
owner: 'trent-j',
repo: 'actions-testing',
packageName: 'com.github.trent-j.actions-test',
numOldVersionsToDelete: 1,
token: process.env.GITHUB_TOKEN as string
owner: 'test-owner',
packageName: 'test-package',
packageType: 'npm',
numOldVersionsToDelete: RATE_LIMIT,
minVersionsToKeep: -1,
ignoreVersions: RegExp('^$'),
token: 'test-token'
}
function getInput(params?: InputParams): Input {

View File

@@ -1,25 +1,179 @@
import {rest} from 'msw'
import {setupServer} from 'msw/node'
import {deletePackageVersion, deletePackageVersions} from '../../src/version'
const githubToken = process.env.GITHUB_TOKEN as string
describe('delete tests - mock rest', () => {
let server = setupServer()
describe.skip('delete tests', () => {
it('deletePackageVersion', async () => {
const response = await deletePackageVersion(
'MDE0OlBhY2thZ2VWZXJzaW9uNjg5OTU1',
githubToken
).toPromise()
expect(response).toBe(true)
beforeEach(() => {
server = setupServer()
server.listen()
})
it('deletePackageVersions', async () => {
const response = await deletePackageVersions(
[
'MDE0OlBhY2thZ2VWZXJzaW9uNjk4Mjc0',
'MDE0OlBhY2thZ2VWZXJzaW9uNjk4Mjcx',
'MDE0OlBhY2thZ2VWZXJzaW9uNjk4MjY3'
],
githubToken
).toPromise()
expect(response).toBe(true)
afterEach(() => {
server.close()
})
it('deletePackageVersion', done => {
server.use(
rest.delete(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions/123',
(req, res, ctx) => {
return res(ctx.status(204))
}
)
)
deletePackageVersion(
'123',
'test-owner',
'test-package',
'npm',
'test-token'
).subscribe(result => {
expect(result).toBe(true)
done()
})
})
it('deletePackageVersions', done => {
let success = 0
server.use(
rest.delete(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions/*',
(req, res, ctx) => {
return res(ctx.status(204))
}
)
)
deletePackageVersions(
['123', '456', '789'],
'test-owner',
'test-package',
'npm',
'test-token'
)
.subscribe(
result => {
expect(result).toBe(true)
success++
},
err => {
// should not get here
done.fail(err)
}
)
.add(() => {
expect(success).toBe(3)
done()
})
})
it('deletePackageVersions - GHES', done => {
process.env.GITHUB_API_URL = 'https://github.someghesinstance.com/api/v3'
let success = 0
server.use(
rest.delete(
'https://github.someghesinstance.com/api/v3/users/test-owner/packages/npm/test-package/versions/*',
(req, res, ctx) => {
return res(ctx.status(204))
}
)
)
deletePackageVersions(
['123', '456', '789'],
'test-owner',
'test-package',
'npm',
'test-token'
)
.subscribe(
result => {
expect(result).toBe(true)
success++
},
err => {
// should not get here
done.fail(err)
}
)
.add(() => {
expect(success).toBe(3)
delete process.env.GITHUB_API_URL
done()
})
})
it('deletePackageVersion - API error', done => {
server.use(
rest.delete(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions/123',
(req, res, ctx) => {
return res(ctx.status(500))
}
)
)
deletePackageVersion(
'123',
'test-owner',
'test-package',
'npm',
'test-token'
).subscribe(
() => {
done.fail('should not get here.')
},
err => {
expect(err).toContain('delete version API failed.')
done()
}
)
})
it('deletePackageVersions - API error for some versions', done => {
let success = 0
let failed = 0
server.use(
rest.delete(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions/:versionId',
(req, res, ctx) => {
if (req.params.versionId === '456') {
return res(ctx.status(500))
}
return res(ctx.status(204))
}
)
)
deletePackageVersions(
['123', '456', '789'],
'test-owner',
'test-package',
'npm',
'test-token'
)
.subscribe(
result => {
expect(result).toBe(true)
success++
},
err => {
expect(err).toContain('delete version API failed.')
failed++
}
)
.add(() => {
expect(success).toBe(2)
expect(failed).toBe(1)
done()
})
})
})

View File

@@ -1,68 +1,200 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
// @ts-ignore
import {mockOldestQueryResponse} from './graphql.mock'
import {rest} from 'msw'
import {setupServer} from 'msw/node'
import {
getOldestVersions as _getOldestVersions,
VersionInfo
RestQueryInfo
} from '../../src/version'
import {Observable} from 'rxjs'
import {getMockedVersionsResponse} from './rest.mock'
import {RATE_LIMIT} from '../../src/delete'
describe.skip('get versions tests -- call graphql', () => {
it('getOldestVersions -- succeeds', done => {
const numVersions = 1
describe('get versions tests -- mock rest', () => {
let server = setupServer()
getOldestVersions({numVersions}).subscribe(versions => {
expect(versions.length).toBe(numVersions)
done()
})
beforeEach(() => {
server = setupServer()
server.listen()
})
it('getOldestVersions -- fails for invalid repo', done => {
getOldestVersions({repo: 'actions-testin'}).subscribe({
error: err => {
expect(err).toBeTruthy()
done()
},
complete: async () => done.fail('no error thrown')
})
afterEach(() => {
server.close()
})
})
describe('get versions tests -- mock graphql', () => {
it('getOldestVersions -- success', done => {
const numVersions = 5
mockOldestQueryResponse(numVersions)
const numVersions = RATE_LIMIT
const resp = getMockedVersionsResponse(numVersions)
getOldestVersions({numVersions}).subscribe(versions => {
expect(versions.length).toBe(numVersions)
server.use(
rest.get(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions',
(req, res, ctx) => {
return res(ctx.status(200), ctx.json(resp))
}
)
)
getOldestVersions({numVersions}).subscribe(result => {
expect(result.versions.length).toBe(numVersions)
for (let i = 0; i < numVersions; i++) {
expect(result.versions[i].id).toBe(resp[i].id)
expect(result.versions[i].version).toBe(resp[i].name)
expect(result.versions[i].created_at).toBe(resp[i].created_at)
}
expect(result.paginate).toBe(true)
expect(result.totalCount).toBe(numVersions)
done()
})
})
it('getOldestVersions -- success - GHES', done => {
const numVersions = RATE_LIMIT
const resp = getMockedVersionsResponse(numVersions)
// set GITHUB_API_URL to a different base url
process.env.GITHUB_API_URL = 'https://github.someghesinstance.com/api/v3'
server.use(
rest.get(
'https://github.someghesinstance.com/api/v3/users/test-owner/packages/npm/test-package/versions',
(req, res, ctx) => {
return res(ctx.status(200), ctx.json(resp))
}
)
)
getOldestVersions({numVersions}).subscribe(result => {
expect(result.versions.length).toBe(numVersions)
for (let i = 0; i < numVersions; i++) {
expect(result.versions[i].id).toBe(resp[i].id)
expect(result.versions[i].version).toBe(resp[i].name)
expect(result.versions[i].created_at).toBe(resp[i].created_at)
}
expect(result.paginate).toBe(true)
expect(result.totalCount).toBe(numVersions)
delete process.env.GITHUB_API_URL
done()
})
})
it('getOldestVersions -- success - container tagged versions', done => {
const numVersions = 6
const numTaggedVersions = 3
const numUntaggedVersions = numVersions - numTaggedVersions
const respTagged = getMockedVersionsResponse(
numTaggedVersions,
0,
'container',
true
)
const respUntagged = getMockedVersionsResponse(
numUntaggedVersions,
numTaggedVersions,
'container',
false
)
const resp = respTagged.concat(respUntagged)
server.use(
rest.get(
'https://api.github.com/users/test-owner/packages/container/test-package/versions',
(req, res, ctx) => {
return res(ctx.status(200), ctx.json(resp))
}
)
)
getOldestVersions({numVersions, packageType: 'container'}).subscribe(
result => {
expect(result.versions.length).toBe(numVersions)
for (let i = 0; i < numVersions; i++) {
expect(result.versions[i].id).toBe(resp[i].id)
expect(result.versions[i].version).toBe(resp[i].name)
expect(result.versions[i].created_at).toBe(resp[i].created_at)
if (i < numTaggedVersions) {
expect(result.versions[i].tagged).toBe(true)
} else {
expect(result.versions[i].tagged).toBe(false)
}
}
expect(result.paginate).toBe(true)
expect(result.totalCount).toBe(numVersions)
done()
}
)
})
it('getOldestVersions -- paginate is false when fetched versions is less than page size', done => {
const numVersions = 5
server.use(
rest.get(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions',
(req, res, ctx) => {
return res(
ctx.status(200),
ctx.json(getMockedVersionsResponse(numVersions))
)
}
)
)
// In the call numVersions is set to RATE_LIMIT, but the response has only 5 versions.
getOldestVersions().subscribe(result => {
expect(result.paginate).toBe(false)
done()
})
})
it('getOldestVersions -- API error', done => {
server.use(
rest.get(
'https://api.github.com/users/test-owner/packages/npm/test-package/versions',
(req, res, ctx) => {
return res(ctx.status(500))
}
)
)
getOldestVersions().subscribe(
() => {
done.fail('should not get here.')
},
err => {
expect(err).toContain('get versions API failed.')
done()
}
)
})
})
interface Params {
owner?: string
repo?: string
packageName?: string
packageType?: string
numVersions?: number
page?: number
token?: string
}
const defaultParams = {
owner: 'trent-j',
repo: 'actions-testing',
packageName: 'com.github.trent-j.actions-test',
numVersions: 3,
token: process.env.GITHUB_TOKEN as string
owner: 'test-owner',
packageName: 'test-package',
packageType: 'npm',
numVersions: RATE_LIMIT,
page: 1,
token: 'test-token'
}
function getOldestVersions(params?: Params): Observable<VersionInfo[]> {
function getOldestVersions(params?: Params): Observable<RestQueryInfo> {
const p: Required<Params> = {...defaultParams, ...params}
return _getOldestVersions(
p.owner,
p.repo,
p.packageName,
p.packageType,
p.numVersions,
p.page,
p.token
)
}

View File

@@ -1,56 +0,0 @@
import {
GraphQlQueryResponseData,
RequestParameters
} from '@octokit/graphql/dist-types/types'
import * as Graphql from '@octokit/graphql'
import {GetVersionsQueryResponse} from '../../src/version'
import SpyInstance = jest.SpyInstance
export function mockGraphql(): SpyInstance<
Promise<GraphQlQueryResponseData>,
[string, (RequestParameters | undefined)?]
> {
return jest.spyOn(Graphql, 'graphql')
}
export function getMockedOldestQueryResponse(
numVersions: number
): GetVersionsQueryResponse {
const versions = []
for (let i = 1; i <= numVersions; ++i) {
versions.push({
node: {
id: i.toString(),
version: `${i}.0.0`
}
})
}
return {
repository: {
packages: {
edges: [
{
node: {
name: 'test',
versions: {
edges: versions.reverse()
}
}
}
]
}
}
}
}
export function mockOldestQueryResponse(
numVersions: number
): ReturnType<typeof mockGraphql> {
return mockGraphql().mockResolvedValue(
getMockedOldestQueryResponse(numVersions)
)
}

View File

@@ -0,0 +1,45 @@
import {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types'
type GetVersionsResponseData =
RestEndpointMethodTypes['packages']['getAllPackageVersionsForPackageOwnedByUser']['response']['data']
type PackageType =
RestEndpointMethodTypes['packages']['getAllPackageVersionsForPackageOwnedByUser']['parameters']['package_type']
export function getMockedVersionsResponse(
numVersions: number,
offset = 0,
packageType = 'npm',
tagged = false
): GetVersionsResponseData {
const versions: GetVersionsResponseData = []
for (let i = 1 + offset; i <= numVersions + offset; ++i) {
const created_at = new Date()
created_at.setUTCFullYear(2000 + Number(i), 1, 1)
let version = {
id: i,
name: `${i}.0.0`,
url: '',
created_at: created_at.toUTCString(),
package_html_url: '',
updated_at: '',
metadata: {
package_type: packageType as PackageType
}
} as GetVersionsResponseData[0]
if (packageType === 'container' && tagged) {
version = {
...version,
metadata: {
package_type: packageType as PackageType,
container: {
tags: [`latest${i}`] as string[]
}
}
}
}
versions.push(version)
}
return versions
}

View File

@@ -15,17 +15,15 @@ inputs:
Defaults to the owner of the repo running the action.
required: false
repo:
description: >
Repo containing the package version to delete.
Defaults to the repo running the action.
required: false
package-name:
description: >
Name of the package containing the version to delete.
Required if dynamically deleting oldest versions.
required: false
required: true
package-type:
description: >
Type of package. Can be one of container, maven, npm, nuget, or rubygems.
required: true
num-old-versions-to-delete:
description: >
@@ -34,6 +32,38 @@ inputs:
required: false
default: "1"
min-versions-to-keep:
description: >
Number of versions to keep starting with the latest version
By default keeps no version.
To delete all versions set this as 0.
required: false
default: "-1"
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. 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"
delete-only-untagged-versions:
description: >
Deletes only untagged versions in case of a container package. Does not work for other package types.
The number of untagged versions to keep can be specified by min-versions-to-keep.
When this is set num-old-versions-to-delete 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.
@@ -44,9 +74,9 @@ inputs:
default: ${{ github.token }}
runs:
using: node12
using: node20
main: dist/index.js
branding:
icon: package
color: blue
color: blue

49528
dist/index.js vendored

File diff suppressed because one or more lines are too long

17490
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -7,9 +7,10 @@
"scripts": {
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"lint": "eslint src/**/*.ts",
"lint": "eslint src/**/*.ts --fix",
"lint-check": "eslint src/**/*.ts",
"test": "jest",
"build": "npm run format-check && npm run lint && npm run test && tsc",
"build": "npm run format-check && npm run lint-check && npm run test && tsc",
"pack": "rm -rf ./lib ./dist && npm run build && ncc build"
},
"repository": {
@@ -24,23 +25,24 @@
"author": "YourNameOrOrganization",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.0",
"@actions/github": "^2.1.1",
"rxjs": "^6.5.4"
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@octokit/rest": "^20.0.2",
"rxjs": "^7.8.1"
},
"devDependencies": {
"@types/jest": "^24.0.23",
"@types/node": "^12.7.12",
"@typescript-eslint/parser": "^2.8.0",
"@zeit/ncc": "^0.20.5",
"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",
"js-yaml": "^3.13.1",
"prettier": "^1.19.1",
"ts-jest": "^24.2.0",
"typescript": "^3.6.4"
"@types/jest": "^29.5.10",
"@types/node": "^20.11.2",
"@typescript-eslint/parser": "^6.19.0",
"@vercel/ncc": "^0.38.1",
"eslint": "^8.55.0",
"eslint-plugin-github": "^4.10.1",
"eslint-plugin-jest": "^27.6.0",
"jest": "^29.7.0",
"jest-circus": "^29.7.0",
"js-yaml": "^4.1.0",
"msw": "^1.3.2",
"prettier": "^3.2.2",
"ts-jest": "^29.1.1"
}
}

View File

@@ -1,25 +1,104 @@
/* eslint-disable i18n-text/no-en */
import {Input} from './input'
import {Observable, of, throwError} from 'rxjs'
import {deletePackageVersions, getOldestVersions} from './version'
import {concatMap, map} from 'rxjs/operators'
import {EMPTY, Observable, of, throwError} from 'rxjs'
import {reduce, concatMap, map, expand, tap} from 'rxjs/operators'
import {
deletePackageVersions,
getOldestVersions,
RestVersionInfo
} from './version'
export function getVersionIds(input: Input): Observable<string[]> {
export const RATE_LIMIT = 100
let totalCount = 0
export function getVersionIds(
owner: string,
packageName: string,
packageType: string,
numVersions: number,
page: number,
token: string
): Observable<RestVersionInfo[]> {
return getOldestVersions(
owner,
packageName,
packageType,
numVersions,
page,
token
).pipe(
expand(value =>
value.paginate
? getOldestVersions(
owner,
packageName,
packageType,
numVersions,
value.page + 1,
token
)
: EMPTY
),
tap(value => (totalCount = totalCount + value.totalCount)),
reduce((acc, value) => acc.concat(value.versions), [] as RestVersionInfo[])
)
}
export function finalIds(input: Input): Observable<string[]> {
if (input.packageVersionIds.length > 0) {
return of(input.packageVersionIds)
const toDelete = Math.min(input.packageVersionIds.length, RATE_LIMIT)
return of(input.packageVersionIds.slice(0, toDelete))
}
if (input.hasOldestVersionQueryInfo()) {
return getOldestVersions(
return getVersionIds(
input.owner,
input.repo,
input.packageName,
input.numOldVersionsToDelete,
input.packageType,
RATE_LIMIT,
1,
input.token
).pipe(map(versionInfo => versionInfo.map(info => info.id)))
}
).pipe(
// This code block executes on all versions of a package starting from oldest
map(value => {
// we need to delete oldest versions first
value.sort((a, b) => {
if (a.created_at === b.created_at) {
return a.id - b.id
}
return (
new Date(a.created_at).getTime() - new Date(b.created_at).getTime()
)
})
/*
Here first filter out the versions that are to be ignored.
Then compute number of versions to delete (toDelete) based on the inputs.
*/
value = value.filter(info => !input.ignoreVersions.test(info.version))
if (input.deleteUntaggedVersions === 'true') {
value = value.filter(info => !info.tagged)
}
let toDelete = 0
if (input.minVersionsToKeep < 0) {
toDelete = Math.min(
value.length,
Math.min(input.numOldVersionsToDelete, RATE_LIMIT)
)
} else {
toDelete = Math.min(
value.length - input.minVersionsToKeep,
RATE_LIMIT
)
}
if (toDelete < 0) return []
return value.map(info => info.id.toString()).slice(0, toDelete)
})
)
}
return throwError(
"Could not get packageVersionIds. Explicitly specify using the 'package-version-ids' input or provide the 'package-name' and 'num-old-versions-to-delete' inputs to dynamically retrieve oldest versions"
"Could not get packageVersionIds. Explicitly specify using the 'package-version-ids' input"
)
}
@@ -28,14 +107,28 @@ export function deleteVersions(input: Input): Observable<boolean> {
return throwError('No token found')
}
if (input.numOldVersionsToDelete <= 0) {
if (!input.checkInput()) {
return throwError('Invalid input combination')
}
if (input.numOldVersionsToDelete <= 0 && input.minVersionsToKeep < 0) {
console.log(
'Number of old versions to delete input is 0 or less, no versions will be deleted'
)
return of(true)
}
return getVersionIds(input).pipe(
concatMap(ids => deletePackageVersions(ids, input.token))
const result = finalIds(input)
return result.pipe(
concatMap(ids =>
deletePackageVersions(
ids,
input.owner,
input.packageName,
input.packageType,
input.token
)
)
)
}

View File

@@ -1,47 +1,100 @@
export interface InputParams {
packageVersionIds?: string[]
owner?: string
repo?: string
packageName?: string
packageType?: string
numOldVersionsToDelete?: number
minVersionsToKeep?: number
ignoreVersions?: RegExp
token?: string
deletePreReleaseVersions?: string
deleteUntaggedVersions?: string
}
const defaultParams = {
packageVersionIds: [],
owner: '',
repo: '',
packageName: '',
packageType: '',
numOldVersionsToDelete: 0,
token: ''
minVersionsToKeep: 0,
ignoreVersions: new RegExp(''),
deletePreReleaseVersions: '',
token: '',
deleteUntaggedVersions: ''
}
export class Input {
packageVersionIds: string[]
owner: string
repo: string
packageName: string
packageType: string
numOldVersionsToDelete: number
minVersionsToKeep: number
ignoreVersions: RegExp
deletePreReleaseVersions: string
token: string
numDeleted: number
deleteUntaggedVersions: string
constructor(params?: InputParams) {
const validatedParams: Required<InputParams> = {...defaultParams, ...params}
this.packageVersionIds = validatedParams.packageVersionIds
this.owner = validatedParams.owner
this.repo = validatedParams.repo
this.packageName = validatedParams.packageName
this.packageType = validatedParams.packageType
this.numOldVersionsToDelete = validatedParams.numOldVersionsToDelete
this.minVersionsToKeep = validatedParams.minVersionsToKeep
this.ignoreVersions = validatedParams.ignoreVersions
this.deletePreReleaseVersions = validatedParams.deletePreReleaseVersions
this.token = validatedParams.token
this.numDeleted = 0
this.deleteUntaggedVersions = validatedParams.deleteUntaggedVersions
}
hasOldestVersionQueryInfo(): boolean {
return !!(
this.owner &&
this.repo &&
this.packageName &&
this.numOldVersionsToDelete > 0 &&
this.numOldVersionsToDelete >= 0 &&
this.token
)
}
checkInput(): boolean {
if (this.packageType.toLowerCase() !== 'container') {
this.deleteUntaggedVersions = 'false'
}
if (
this.numOldVersionsToDelete > 1 &&
(this.minVersionsToKeep >= 0 ||
this.deletePreReleaseVersions === 'true' ||
this.deleteUntaggedVersions === 'true')
) {
return false
}
if (this.packageType === '' || this.packageName === '') {
return false
}
if (this.deletePreReleaseVersions === 'true') {
this.minVersionsToKeep =
this.minVersionsToKeep > 0 ? this.minVersionsToKeep : 0
this.ignoreVersions = new RegExp('^(0|[1-9]\\d*)((\\.(0|[1-9]\\d*))*)$')
}
if (this.deleteUntaggedVersions === 'true') {
this.minVersionsToKeep =
this.minVersionsToKeep > 0 ? this.minVersionsToKeep : 0
}
if (this.minVersionsToKeep >= 0) {
this.numOldVersionsToDelete = 0
}
return true
}
}

View File

@@ -11,10 +11,18 @@ function getActionInput(): Input {
? getInput('package-version-ids').split(',')
: [],
owner: getInput('owner') ? getInput('owner') : context.repo.owner,
repo: getInput('repo') ? getInput('repo') : context.repo.repo,
packageName: getInput('package-name'),
packageType: getInput('package-type'),
numOldVersionsToDelete: Number(getInput('num-old-versions-to-delete')),
token: getInput('token')
minVersionsToKeep: Number(getInput('min-versions-to-keep')),
ignoreVersions: RegExp(getInput('ignore-versions')),
deletePreReleaseVersions: getInput(
'delete-only-pre-release-versions'
).toLowerCase(),
token: getInput('token'),
deleteUntaggedVersions: getInput(
'delete-only-untagged-versions'
).toLowerCase()
})
}
@@ -24,7 +32,10 @@ function run(): Observable<boolean> {
catchError(err => throwError(err))
)
} catch (error) {
return throwError(error.message)
if (error instanceof Error) {
return throwError(error.message)
}
return throwError(error)
}
}

View File

@@ -1,66 +1,67 @@
import {from, Observable, merge, throwError, of} from 'rxjs'
import {graphql} from '@octokit/graphql'
import {catchError, map, tap} from 'rxjs/operators'
import {GraphQlQueryResponse} from '@octokit/graphql/dist-types/types'
import {Octokit} from '@octokit/rest'
import {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types'
export interface DeletePackageVersionMutationResponse {
deletePackageVersion: {
success: boolean
}
}
const mutation = `
mutation deletePackageVersion($packageVersionId: String!) {
deletePackageVersion(input: {packageVersionId: $packageVersionId}) {
success
}
}`
let deleted = 0
type PackageType =
RestEndpointMethodTypes['packages']['getAllPackageVersionsForPackageOwnedByUser']['parameters']['package_type']
export function deletePackageVersion(
packageVersionId: string,
owner: string,
packageName: string,
packageType: string,
token: string
): Observable<boolean> {
const octokit = new Octokit({
auth: token,
baseUrl: process.env.GITHUB_API_URL || 'https://api.github.com'
})
const package_version_id = +packageVersionId
const package_type: PackageType = packageType as PackageType
deleted += 1
return from(
graphql(mutation, {
packageVersionId,
headers: {
authorization: `token ${token}`,
Accept: 'application/vnd.github.package-deletes-preview+json'
}
}) as Promise<DeletePackageVersionMutationResponse>
octokit.rest.packages.deletePackageVersionForUser({
package_type,
package_name: packageName,
username: owner,
package_version_id
})
).pipe(
catchError((err: GraphQlQueryResponse) => {
const msg = 'delete version mutation failed.'
catchError(err => {
const msg = 'delete version API failed.'
return throwError(
err.errors && err.errors.length > 0
? `${msg} ${err.errors[0].message}`
: `${msg} verify input parameters are correct`
: `${msg} ${err.message} \n${deleted - 1} versions deleted till now.`
)
}),
map(response => response.deletePackageVersion.success)
map(response => response.status === 204)
)
}
export function deletePackageVersions(
packageVersionIds: string[],
owner: string,
packageName: string,
packageType: string,
token: string
): Observable<boolean> {
if (packageVersionIds.length === 0) {
console.log('no package version ids found, no versions will be deleted')
return of(true)
}
const deletes = packageVersionIds.map(id =>
deletePackageVersion(id, token).pipe(
deletePackageVersion(id, owner, packageName, packageType, token).pipe(
tap(result => {
if (result) {
console.log(`version with id: ${id}, deleted`)
} else {
if (!result) {
console.log(`version with id: ${id}, not deleted`)
}
})
)
)
console.log(`Total versions deleted till now: ${deleted}`)
return merge(...deletes)
}

View File

@@ -1,111 +1,83 @@
import {graphql} from '@octokit/graphql'
import {GraphQlQueryResponse} from '@octokit/graphql/dist-types/types'
import {Observable, from, throwError} from 'rxjs'
/* eslint-disable @typescript-eslint/no-unused-vars */
import {from, Observable, merge, throwError, of} from 'rxjs'
import {catchError, map} from 'rxjs/operators'
import {Octokit} from '@octokit/rest'
import {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types'
export interface VersionInfo {
id: string
export interface RestVersionInfo {
id: number
version: string
created_at: string
tagged: boolean
}
export interface GetVersionsQueryResponse {
repository: {
packages: {
edges: {
node: {
name: string
versions: {
edges: {node: VersionInfo}[]
}
}
}[]
}
}
export interface RestQueryInfo {
versions: RestVersionInfo[]
page: number
paginate: boolean
totalCount: number
}
const query = `
query getVersions($owner: String!, $repo: String!, $package: String!, $last: Int!) {
repository(owner: $owner, name: $repo) {
packages(first: 1, names: [$package]) {
edges {
node {
name
versions(last: $last) {
edges {
node {
id
version
}
}
}
}
}
}
}
}`
export function queryForOldestVersions(
owner: string,
repo: string,
packageName: string,
numVersions: number,
token: string
): Observable<GetVersionsQueryResponse> {
return from(
graphql(query, {
owner,
repo,
package: packageName,
last: numVersions,
headers: {
authorization: `token ${token}`,
Accept: 'application/vnd.github.packages-preview+json'
}
}) as Promise<GetVersionsQueryResponse>
).pipe(
catchError((err: GraphQlQueryResponse) => {
const msg = 'query for oldest version failed.'
return throwError(
err.errors && err.errors.length > 0
? `${msg} ${err.errors[0].message}`
: `${msg} verify input parameters are correct`
)
})
)
}
type PackageType =
RestEndpointMethodTypes['packages']['getAllPackageVersionsForPackageOwnedByUser']['parameters']['package_type']
type GetVersionsResponse =
RestEndpointMethodTypes['packages']['getAllPackageVersionsForPackageOwnedByUser']['response']['data']
export function getOldestVersions(
owner: string,
repo: string,
packageName: string,
packageType: string,
numVersions: number,
page: number,
token: string
): Observable<VersionInfo[]> {
return queryForOldestVersions(
owner,
repo,
packageName,
numVersions,
token
): Observable<RestQueryInfo> {
const octokit = new Octokit({
auth: token,
baseUrl: process.env.GITHUB_API_URL || 'https://api.github.com'
})
const package_type: PackageType = packageType as PackageType
return from(
octokit.rest.packages.getAllPackageVersionsForPackageOwnedByUser({
package_type,
package_name: packageName,
username: owner,
per_page: numVersions,
page
})
).pipe(
map(result => {
if (result.repository.packages.edges.length < 1) {
throwError(
`package: ${packageName} not found for owner: ${owner} in repo: ${repo}`
)
catchError(err => {
const msg = 'get versions API failed.'
return throwError(
err.errors && err.errors.length > 0
? `${msg} ${err.errors[0].message}`
: `${msg} ${err.message}`
)
}),
map(response => {
const resp = {
versions: response.data.map((version: GetVersionsResponse[0]) => {
let tagged = false
if (
package_type === 'container' &&
version.metadata &&
version.metadata.container
) {
tagged = version.metadata.container.tags.length > 0
}
return {
id: version.id,
version: version.name,
created_at: version.created_at,
tagged
}
}),
page,
paginate: response.data.length === numVersions,
totalCount: response.data.length
}
const versions = result.repository.packages.edges[0].node.versions.edges
if (versions.length !== numVersions) {
console.log(
`number of versions requested was: ${numVersions}, but found: ${versions.length}`
)
}
return versions
.map(value => ({id: value.node.id, version: value.node.version}))
.reverse()
return resp
})
)
}