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