Created
October 11, 2022 12:23
-
-
Save jkremser/cbed1e82bf7f80b689176b5cedac1f1a to your computer and use it in GitHub Desktop.
remove assets from existing (/same) release
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Remove previous stuff (in case the release is run again) | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
run: | | |
curl_args=(-s -H "Authorization: token ${GITHUB_TOKEN}") | |
curl_args+=(-H "Accept: application/vnd.github.v3+json") | |
release_id="$(curl "${curl_args[@]}" "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases?per_page=10" | jq "map(select(.name == \"${GITHUB_REF_NAME}\"))" | jq -r '.[0].id')" | |
[ -z "${release_id}" ] && echo "No previous release with tag has been detected" && exit 0 | |
ids=$(curl "${curl_args[@]}" -X GET https://api.github.com/repos/jkremser/log2rbac-operator/releases/${release_id}/assets | jq '.[] | select(.name=="provenance.att.sig" or .name=="provenance.att") | .id') | |
echo "Removing assets from release (id: ${release_id}) with following asset ids: '${ids}'" | |
for id in $(echo ${ids}) | |
curl -X DELETE https://uploads.github.com/repos/jkremser/log2rbac-operator/releases/assets/${id} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment