@@ -2646,30 +2646,29 @@ jobs:
26462646 # * nothing else failed (allows manual restarts)
26472647 # * the workflow got cancelled
26482648 if : ${{ always() && needs.base-build.result == 'success' && (!contains(needs.*.result, 'failure') || cancelled()) }}
2649- permissions :
2650- actions : write
26512649 runs-on : ubuntu-latest
26522650 timeout-minutes : 60
26532651 steps :
26542652
2655- - name : Delete Workspace Artifact
2656- run : |
2657- ARTIFACT_ID=$(gh api /repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts --jq ".artifacts[] | select(.name == \"${NAME}\") | .id")
2658- echo ${ARTIFACT_ID}
2659- if [ -n "$ARTIFACT_ID" ]; then
2660- gh api /repos/${GITHUB_REPOSITORY}/actions/artifacts/${ARTIFACT_ID} -X DELETE
2661- fi
2662- env :
2663- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2664- NAME : build.tar.zst
2653+ - name : Delete Workflow Artifacts
2654+ uses : actions/github-script@v8
2655+ with :
2656+ script : |
2657+ const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
2658+ owner: context.repo.owner,
2659+ repo: context.repo.repo,
2660+ run_id: context.runId
2661+ });
2662+ console.log(artifacts);
2663+ const job = github.context.job;
2664+ for (const artifact of artifacts.data.artifacts) {
2665+ if (artifact.name === "build.tar.zst" || (artifact.name.startsWith("dev-build") && job.status === 'cancelled')) {
2666+ console.log("removing " + artifact.name);
2667+ await github.rest.actions.deleteArtifact({
2668+ owner: context.repo.owner,
2669+ repo: context.repo.repo,
2670+ artifact_id: artifact.id
2671+ });
2672+ }
2673+ }
26652674
2666- - name : Delete Dev Build Artifact
2667- if : ${{ contains(github.event.pull_request.labels.*.name, 'ci:dev-build') && cancelled() }}
2668- run : |
2669- ARTIFACT_ID=$(gh api /repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts --jq ".artifacts[] | select(.name == \"${NAME}\") | .id")
2670- if [ -n "$ARTIFACT_ID" ]; then
2671- gh api /repos/${GITHUB_REPOSITORY}/actions/artifacts/${ARTIFACT_ID} -X DELETE
2672- fi
2673- env :
2674- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2675- NAME : dev-build_${{github.event.pull_request.number || github.run_id}}.zip
0 commit comments