@@ -1570,49 +1570,38 @@ jobs:
1570
1570
- macos_x64_test
1571
1571
1572
1572
steps :
1573
- - name : Determine current artifacts endpoint
1574
- id : actions_runtime
1575
- uses : actions/github-script@v7
1576
- with :
1577
- script : " return { url: process.env['ACTIONS_RUNTIME_URL'], token: process.env['ACTIONS_RUNTIME_TOKEN'] }"
1578
-
1579
1573
- name : Display current artifacts
1580
- run : >
1581
- curl -s -H 'Accept: application/json;api-version=6.0-preview'
1582
- -H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}'
1583
- '${{ fromJson(steps.actions_runtime.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview'
1574
+ run : |
1575
+ curl -sL \
1576
+ -H 'Accept: application/vnd.github+json' \
1577
+ -H 'Authorization: Bearer ${{ github.token }}' \
1578
+ -H 'X-GitHub-Api-Version: 2022-11-28' \
1579
+ '${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts'
1584
1580
1585
1581
- name : Delete transient artifacts
1586
- run : >
1587
- for url in `
1588
- curl -s -H 'Accept: application/json;api-version=6.0-preview'
1589
- -H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}'
1590
- '${{ fromJson(steps.actions_runtime.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview' |
1591
- jq -r -c '.value | map(select(.name|startswith("transient_"))) | .[].url'`; do
1592
- curl -s -H 'Accept: application/json;api-version=6.0-preview'
1593
- -H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}'
1594
- -X DELETE "${url}";
1595
- done
1596
-
1597
- - name : Fetch remaining artifacts (test results)
1598
- uses : actions/download-artifact@v4
1599
- with :
1600
- path : test-results
1601
-
1602
- - name : Delete remaining artifacts
1603
- run : >
1604
- for url in `
1605
- curl -s -H 'Accept: application/json;api-version=6.0-preview'
1606
- -H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}'
1607
- '${{ fromJson(steps.actions_runtime.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview' |
1608
- jq -r -c '.value | .[].url'`; do
1609
- curl -s -H 'Accept: application/json;api-version=6.0-preview'
1610
- -H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}'
1611
- -X DELETE "${url}";
1582
+ run : |
1583
+ # Find and remove all transient artifacts
1584
+ # See: https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28
1585
+ ALL_ARTIFACT_IDS="$(curl -sL \
1586
+ -H 'Accept: application/vnd.github+json' \
1587
+ -H 'Authorization: Bearer ${{ github.token }}' \
1588
+ -H 'X-GitHub-Api-Version: 2022-11-28' \
1589
+ '${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts')"
1590
+ BUNDLE_ARTIFACT_IDS="$(echo "$ALL_ARTIFACT_IDS" | jq -r -c '.artifacts | map(select(.name|startswith("transient_"))) | .[].id')"
1591
+ for id in $BUNDLE_ARTIFACT_IDS; do
1592
+ echo "Removing $id"
1593
+ curl -sL \
1594
+ -X DELETE \
1595
+ -H 'Accept: application/vnd.github+json' \
1596
+ -H 'Authorization: Bearer ${{ github.token }}' \
1597
+ -H 'X-GitHub-Api-Version: 2022-11-28' \
1598
+ "${{ github.api_url }}/repos/${{ github.repository }}/actions/artifacts/$id" \
1599
+ || echo "Failed to remove bundle"
1612
1600
done
1613
1601
1614
1602
- name : Upload a combined test results artifact
1615
- uses : actions/upload-artifact@v4
1603
+ uses : actions/upload-artifact/merge @v4
1616
1604
with :
1617
1605
name : test-results_${{ needs.prerequisites.outputs.bundle_id }}
1618
- path : test-results
1606
+ separate-directories : false
1607
+ delete-merged : true
0 commit comments