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