Skip to content

vulnerability fixes

vulnerability fixes #3

name: Delete packages and releases
on:
workflow_call:
inputs:
tag:
description: 'Tag to delete'
required: true
type: string
secrets:
GITHUB_TOKEN:

Check failure on line 11 in .github/workflows/delete-packages-and-releases.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/delete-packages-and-releases.yml

Invalid workflow file

secret name `GITHUB_TOKEN` within `workflow_call` can not be used since it would collide with system reserved name
required: true
workflow_dispatch:
inputs:
tag:
description: 'Tag to delete'
required: true
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
delete:
name: Delete Old Packages and Releases
permissions:
contents: write # For deleting releases and tags
packages: write # For deleting npm packages
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/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/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