forked from JayPNanduri/ast-cli-javascript-wrapper-jay
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdelete-packages-and-releases.yml
More file actions
55 lines (48 loc) · 1.91 KB
/
Copy pathdelete-packages-and-releases.yml
File metadata and controls
55 lines (48 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Delete packages and releases
on:
workflow_call:
inputs:
tag:
description: 'Tag to delete'
required: true
type: string
workflow_dispatch:
inputs:
tag:
description: 'Tag to delete'
required: true
permissions:
contents: read
jobs:
delete:
permissions:
contents: write
packages: write
runs-on: cx-public-ubuntu-x64
steps:
- name: Delete npm packages
continue-on-error: true
env:
INPUT_TAG: ${{ inputs.tag }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Deleting all npm packages whose name ends with '-${INPUT_TAG}.0'"
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"))
for versionId in "${VERSION_IDS[@]}"
do
echo "Deleting version $versionId..."
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"
echo "Version $versionId deleted successfully!"
done
- name: Delete releases and tags
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INPUT_TAG: ${{ inputs.tag }}
run: |
gh release list --limit 100 --json tagName \
--jq ".[] | select(.tagName | contains(\"-${INPUT_TAG}.0\")) | .tagName" \
| while IFS= read -r tag; do
echo "Deleting release and tag: $tag"
gh release delete "$tag" --yes --cleanup-tag || true
done