8336928: GHA: Bundle artifacts removal broken
Reviewed-by: ihse
This commit is contained in:
parent
219e1eb13a
commit
98562166e4
33
.github/workflows/main.yml
vendored
33
.github/workflows/main.yml
vendored
@ -363,26 +363,23 @@ jobs:
|
|||||||
- test-windows-x64
|
- test-windows-x64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Hack to get hold of the api environment variables that are only defined for actions
|
|
||||||
- name: 'Get API configuration'
|
|
||||||
id: api
|
|
||||||
uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
script: 'return { url: process.env["ACTIONS_RUNTIME_URL"], token: process.env["ACTIONS_RUNTIME_TOKEN"] }'
|
|
||||||
|
|
||||||
- name: 'Remove bundle artifacts'
|
- name: 'Remove bundle artifacts'
|
||||||
run: |
|
run: |
|
||||||
# Find and remove all bundle artifacts
|
# Find and remove all bundle artifacts
|
||||||
ALL_ARTIFACT_URLS="$(curl -s \
|
# See: https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28
|
||||||
-H 'Accept: application/json;api-version=6.0-preview' \
|
ALL_ARTIFACT_IDS="$(curl -sL \
|
||||||
-H 'Authorization: Bearer ${{ fromJson(steps.api.outputs.result).token }}' \
|
-H 'Accept: application/vnd.github+json' \
|
||||||
'${{ fromJson(steps.api.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview')"
|
-H 'Authorization: Bearer ${{ github.token }}' \
|
||||||
BUNDLE_ARTIFACT_URLS="$(echo "$ALL_ARTIFACT_URLS" | jq -r -c '.value | map(select(.name|startswith("bundles-"))) | .[].url')"
|
-H 'X-GitHub-Api-Version: 2022-11-28' \
|
||||||
for url in $BUNDLE_ARTIFACT_URLS; do
|
'${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts')"
|
||||||
echo "Removing $url"
|
BUNDLE_ARTIFACT_IDS="$(echo "$ALL_ARTIFACT_IDS" | jq -r -c '.artifacts | map(select(.name|startswith("bundles-"))) | .[].id')"
|
||||||
curl -s \
|
for id in $BUNDLE_ARTIFACT_IDS; do
|
||||||
-H 'Accept: application/json;api-version=6.0-preview' \
|
echo "Removing $id"
|
||||||
-H 'Authorization: Bearer ${{ fromJson(steps.api.outputs.result).token }}' \
|
curl -sL \
|
||||||
-X DELETE "$url" \
|
-X DELETE \
|
||||||
|
-H 'Accept: application/vnd.github+json' \
|
||||||
|
-H 'Authorization: Bearer ${{ github.token }}' \
|
||||||
|
-H 'X-GitHub-Api-Version: 2022-11-28' \
|
||||||
|
"${{ github.api_url }}/repos/${{ github.repository }}/actions/artifacts/$id" \
|
||||||
|| echo "Failed to remove bundle"
|
|| echo "Failed to remove bundle"
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user