|
14 | 14 | required: true |
15 | 15 |
|
16 | 16 | permissions: |
17 | | - id-token: write |
18 | | - contents: write |
19 | | - packages: write |
20 | | - |
| 17 | + contents: read |
21 | 18 |
|
22 | 19 | jobs: |
23 | 20 | delete: |
| 21 | + permissions: |
| 22 | + contents: write |
| 23 | + packages: write |
24 | 24 | runs-on: cx-public-ubuntu-x64 |
25 | 25 | steps: |
26 | 26 |
|
27 | 27 | - name: Delete npm packages |
28 | 28 | continue-on-error: true |
| 29 | + env: |
| 30 | + INPUT_TAG: ${{ inputs.tag }} |
| 31 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
29 | 32 | run: | |
| 33 | + echo "Deleting all npm packages whose name ends with '-${INPUT_TAG}.0'" |
30 | 34 |
|
31 | | - echo "Deleting all npm packages whose name ends with '-${{inputs.tag}}.0'" |
32 | | -
|
33 | | - VERSION_IDS=($(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/orgs/Checkmarx/packages/npm/ast-cli-javascript-wrapper-runtime-cli/versions | jq '.[]|select(.name | contains("-${{inputs.tag}}.0"))|.id')) |
| 35 | + VERSION_IDS=($(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GH_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/orgs/Checkmarx/packages/npm/ast-cli-javascript-wrapper-runtime-cli/versions | jq ".[]|select(.name | contains(\"-${INPUT_TAG}.0\"))|.id")) |
34 | 36 |
|
35 | 37 | for versionId in "${VERSION_IDS[@]}" |
36 | 38 | do |
37 | 39 | echo "Deleting version $versionId..." |
38 | | - curl -L -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/orgs/Checkmarx/packages/npm/ast-cli-javascript-wrapper-runtime-cli/versions/$versionId" |
| 40 | + curl -L -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GH_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/orgs/Checkmarx/packages/npm/ast-cli-javascript-wrapper-runtime-cli/versions/$versionId" |
39 | 41 | echo "Version $versionId deleted successfully!" |
40 | 42 | done |
41 | 43 |
|
42 | 44 | - name: Delete releases and tags |
43 | 45 | continue-on-error: true |
44 | | - uses: dev-drprasad/delete-older-releases@dfbe6be2a006e9475dfcbe5b8d201f1824c2a9fe #v0.3.4 |
45 | 46 | env: |
46 | | - GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
47 | | - with: |
48 | | - keep_latest: 0 |
49 | | - delete_tag_pattern: "-${{inputs.tag}}.0" |
50 | | - delete_tags: true |
| 47 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + INPUT_TAG: ${{ inputs.tag }} |
| 49 | + run: | |
| 50 | + gh release list --limit 100 --json tagName \ |
| 51 | + --jq ".[] | select(.tagName | contains(\"-${INPUT_TAG}.0\")) | .tagName" \ |
| 52 | + | while IFS= read -r tag; do |
| 53 | + echo "Deleting release and tag: $tag" |
| 54 | + gh release delete "$tag" --yes --cleanup-tag || true |
| 55 | + done |
0 commit comments