@@ -333,26 +333,23 @@ jobs:
333
333
- test-windows-x64
334
334
335
335
steps :
336
- # Hack to get hold of the api environment variables that are only defined for actions
337
- - name : ' Get API configuration'
338
- id : api
339
- uses : actions/github-script@v7
340
- with :
341
- script : ' return { url: process.env["ACTIONS_RUNTIME_URL"], token: process.env["ACTIONS_RUNTIME_TOKEN"] }'
342
-
343
336
- name : ' Remove bundle artifacts'
344
337
run : |
345
338
# Find and remove all bundle artifacts
346
- ALL_ARTIFACT_URLS="$(curl -s \
347
- -H 'Accept: application/json;api-version=6.0-preview' \
348
- -H 'Authorization: Bearer ${{ fromJson(steps.api.outputs.result).token }}' \
349
- '${{ fromJson(steps.api.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview')"
350
- BUNDLE_ARTIFACT_URLS="$(echo "$ALL_ARTIFACT_URLS" | jq -r -c '.value | map(select(.name|startswith("bundles-"))) | .[].url')"
351
- for url in $BUNDLE_ARTIFACT_URLS; do
352
- echo "Removing $url"
353
- curl -s \
354
- -H 'Accept: application/json;api-version=6.0-preview' \
355
- -H 'Authorization: Bearer ${{ fromJson(steps.api.outputs.result).token }}' \
356
- -X DELETE "$url" \
339
+ # See: https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28
340
+ ALL_ARTIFACT_IDS="$(curl -sL \
341
+ -H 'Accept: application/vnd.github+json' \
342
+ -H 'Authorization: Bearer ${{ github.token }}' \
343
+ -H 'X-GitHub-Api-Version: 2022-11-28' \
344
+ '${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts')"
345
+ BUNDLE_ARTIFACT_IDS="$(echo "$ALL_ARTIFACT_IDS" | jq -r -c '.artifacts | map(select(.name|startswith("bundles-"))) | .[].id')"
346
+ for id in $BUNDLE_ARTIFACT_IDS; do
347
+ echo "Removing $id"
348
+ curl -sL \
349
+ -X DELETE \
350
+ -H 'Accept: application/vnd.github+json' \
351
+ -H 'Authorization: Bearer ${{ github.token }}' \
352
+ -H 'X-GitHub-Api-Version: 2022-11-28' \
353
+ "${{ github.api_url }}/repos/${{ github.repository }}/actions/artifacts/$id" \
357
354
|| echo "Failed to remove bundle"
358
355
done
0 commit comments