Skip to content

Commit

Permalink
Backport 98562166e4a4c8921709014423c6cbc993aa0d97
Browse files Browse the repository at this point in the history
  • Loading branch information
zzambers committed Aug 13, 2024
1 parent d4adbe3 commit 20dcc4b
Showing 1 changed file with 27 additions and 38 deletions.
65 changes: 27 additions & 38 deletions .github/workflows/submit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1579,49 +1579,38 @@ jobs:
- macos_x64_test

steps:
- name: Determine current artifacts endpoint
id: actions_runtime
uses: actions/github-script@v7
with:
script: "return { url: process.env['ACTIONS_RUNTIME_URL'], token: process.env['ACTIONS_RUNTIME_TOKEN'] }"

- name: Display current artifacts
run: >
curl -s -H 'Accept: application/json;api-version=6.0-preview'
-H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}'
'${{ fromJson(steps.actions_runtime.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview'
run: |
curl -sL \
-H 'Accept: application/vnd.github+json' \
-H 'Authorization: Bearer ${{ github.token }}' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
'${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts'
- name: Delete transient artifacts
run: >
for url in `
curl -s -H 'Accept: application/json;api-version=6.0-preview'
-H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}'
'${{ fromJson(steps.actions_runtime.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview' |
jq -r -c '.value | map(select(.name|startswith("transient_"))) | .[].url'`; do
curl -s -H 'Accept: application/json;api-version=6.0-preview'
-H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}'
-X DELETE "${url}";
done
- name: Fetch remaining artifacts (test results)
uses: actions/download-artifact@v4
with:
path: test-results

- name: Delete remaining artifacts
run: >
for url in `
curl -s -H 'Accept: application/json;api-version=6.0-preview'
-H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}'
'${{ fromJson(steps.actions_runtime.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview' |
jq -r -c '.value | .[].url'`; do
curl -s -H 'Accept: application/json;api-version=6.0-preview'
-H 'Authorization: Bearer ${{ fromJson(steps.actions_runtime.outputs.result).token }}'
-X DELETE "${url}";
run: |
# Find and remove all transient artifacts
# See: https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28
ALL_ARTIFACT_IDS="$(curl -sL \
-H 'Accept: application/vnd.github+json' \
-H 'Authorization: Bearer ${{ github.token }}' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
'${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts')"
BUNDLE_ARTIFACT_IDS="$(echo "$ALL_ARTIFACT_IDS" | jq -r -c '.artifacts | map(select(.name|startswith("transient_"))) | .[].id')"
for id in $BUNDLE_ARTIFACT_IDS; do
echo "Removing $id"
curl -sL \
-X DELETE \
-H 'Accept: application/vnd.github+json' \
-H 'Authorization: Bearer ${{ github.token }}' \
-H 'X-GitHub-Api-Version: 2022-11-28' \
"${{ github.api_url }}/repos/${{ github.repository }}/actions/artifacts/$id" \
|| echo "Failed to remove bundle"
done
- name: Upload a combined test results artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact/merge@v4
with:
name: test-results_${{ needs.prerequisites.outputs.bundle_id }}
path: test-results
separate-directories: false
delete-merged: true

0 comments on commit 20dcc4b

Please sign in to comment.