Skip to content

Commit edbdf05

Browse files
committed
8336928: GHA: Bundle artifacts removal broken
Reviewed-by: sgehwolf Backport-of: 98562166e4a4c8921709014423c6cbc993aa0d97
1 parent 1ca84ad commit edbdf05

File tree

1 file changed

+27
-38
lines changed

1 file changed

+27
-38
lines changed

.github/workflows/submit.yml

+27-38
Original file line numberDiff line numberDiff line change
@@ -1582,49 +1582,38 @@ jobs:
15821582
- macos_x64_test
15831583

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

0 commit comments

Comments
 (0)