Skip to content

delete_all_artifacts #3264

delete_all_artifacts

delete_all_artifacts #3264

name: Delete Calling job's artifacts
on: repository_dispatch
jobs:
delete-calling-jobs-artifacts:
runs-on: ubuntu-latest
steps:
- name: Delete artifacts
if: github.event.action == 'delete_all_artifacts'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PARENT_REPO="${{ github.event.client_payload.parent_repo }}"
PARENT_RUNID="${{ github.event.client_payload.parent_runid }}"
gh api "repos/${PARENT_REPO}/actions/runs/${PARENT_RUNID}/artifacts" \
--paginate --jq '.artifacts[].id' | while read -r ARTIFACT_ID; do
echo "Deleting artifact ${ARTIFACT_ID}..."
gh api -X DELETE "repos/${PARENT_REPO}/actions/artifacts/${ARTIFACT_ID}" || true
done