@@ -362,26 +362,23 @@ jobs:
362
362
- test-windows-x64
363
363
364
364
steps :
365
- # Hack to get hold of the api environment variables that are only defined for actions
366
- - name : ' Get API configuration'
367
- id : api
368
- uses : actions/github-script@v7
369
- with :
370
- script : ' return { url: process.env["ACTIONS_RUNTIME_URL"], token: process.env["ACTIONS_RUNTIME_TOKEN"] }'
371
-
372
365
- name : ' Remove bundle artifacts'
373
366
run : |
374
367
# Find and remove all bundle artifacts
375
- ALL_ARTIFACT_URLS="$(curl -s \
376
- -H 'Accept: application/json;api-version=6.0-preview' \
377
- -H 'Authorization: Bearer ${{ fromJson(steps.api.outputs.result).token }}' \
378
- '${{ fromJson(steps.api.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview')"
379
- BUNDLE_ARTIFACT_URLS="$(echo "$ALL_ARTIFACT_URLS" | jq -r -c '.value | map(select(.name|startswith("bundles-"))) | .[].url')"
380
- for url in $BUNDLE_ARTIFACT_URLS; do
381
- echo "Removing $url"
382
- curl -s \
383
- -H 'Accept: application/json;api-version=6.0-preview' \
384
- -H 'Authorization: Bearer ${{ fromJson(steps.api.outputs.result).token }}' \
385
- -X DELETE "$url" \
368
+ # See: https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28
369
+ ALL_ARTIFACT_IDS="$(curl -sL \
370
+ -H 'Accept: application/vnd.github+json' \
371
+ -H 'Authorization: Bearer ${{ github.token }}' \
372
+ -H 'X-GitHub-Api-Version: 2022-11-28' \
373
+ '${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts')"
374
+ BUNDLE_ARTIFACT_IDS="$(echo "$ALL_ARTIFACT_IDS" | jq -r -c '.artifacts | map(select(.name|startswith("bundles-"))) | .[].id')"
375
+ for id in $BUNDLE_ARTIFACT_IDS; do
376
+ echo "Removing $id"
377
+ curl -sL \
378
+ -X DELETE \
379
+ -H 'Accept: application/vnd.github+json' \
380
+ -H 'Authorization: Bearer ${{ github.token }}' \
381
+ -H 'X-GitHub-Api-Version: 2022-11-28' \
382
+ "${{ github.api_url }}/repos/${{ github.repository }}/actions/artifacts/$id" \
386
383
|| echo "Failed to remove bundle"
387
384
done
0 commit comments