Skip to content

Commit b4ea395

Browse files
committed
Replace delete-artifact action with REST api calls using gh CLI
1 parent b53dd61 commit b4ea395

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

.github/workflows/main.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,19 +2646,30 @@ 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
26492651
runs-on: ubuntu-latest
26502652
timeout-minutes: 60
26512653
steps:
26522654

26532655
- name: Delete Workspace Artifact
2654-
uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0
2655-
with:
2656-
name: build.tar.zst
2657-
useGlob: false
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
26582665

26592666
- name: Delete Dev Build Artifact
2660-
uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0
26612667
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci:dev-build') && cancelled() }}
2662-
with:
2663-
name: dev-build_${{github.event.pull_request.number || github.run_id}}.zip
2664-
useGlob: false
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

Comments
 (0)