Skip to content

Commit

Permalink
Merge pull request #5 from OmegaLambda1998/OmegaLambda1998-patch-1
Browse files Browse the repository at this point in the history
Create cancel_workflow_runs.yml
  • Loading branch information
OmegaLambda1998 authored Jul 19, 2024
2 parents 1d0264f + 62e7fe2 commit aab0f02
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/cancel_workflow_runs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Delete branch
on: delete
jobs:
delete_workflow_runs:
runs-on: ubuntu-latest
steps:
- name: Delete workflow runs for deleted branch
id: delete-workflow-runs-for-deleted-branch
if: github.event.ref_type == 'branch'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_BRANCH: ${{ github.event.ref }}
GITHUB_REPOSITORY_URL: ${{ github.event.repository.url }}
run: |
echo "Deleting workflow runs for deleted branch ${GITHUB_BRANCH}"
for id in $(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" ${GITHUB_REPOSITORY_URL}/actions/runs?branch=${GITHUB_BRANCH} | jq '.workflow_runs | .[] | .id'); do
curl -s -X DELETE -H "Authorization: Bearer ${GITHUB_TOKEN}" ${GITHUB_REPOSITORY_URL}/actions/runs/${id}
echo "Deleted workflow run ${id}"
done

0 comments on commit aab0f02

Please sign in to comment.