Cancel in-progress and queued workflow runs for a branch.
- Cancels all in-progress runs for a branch
- Cancels all queued runs for a branch
name: Cancel Runs Boton:
issue_comment:
types: [created]jobs:
cancel:
if: github.event.issue.pull_request && contains(github.event.comment.body, '/cancel-runs')runs-on: ubuntu-lateststeps:
- name: Get branchid: branchrun: | branch=$(gh pr view ${{ github.event.issue.number }} --json headRefName --jq '.headRefName') echo "branch=$branch" >> $GITHUB_OUTPUT - uses: libnudget/cancel@v1with:
branch: ${{ steps.branch.outputs.branch }}name: Cancel Runs Boton:
pull_request:
types: [labeled]jobs:
cancel:
if: github.event.label.name == 'cancel-runs'runs-on: ubuntu-lateststeps:
- uses: libnudget/cancel@v1with:
pr_number: ${{ github.event.pull_request.number }}token: ${{ secrets.GITHUB_TOKEN }}# Comment on PR
/cancel-runs
# Label PR
cancel-runs| Input | Description | Required | Default |
|---|---|---|---|
| repo | Repository | No | current repo |
| branch | Branch to cancel runs for | No* | - |
| pr_number | PR number to get branch from | No* | - |
| token | GitHub token | Yes | - |
*Either branch or pr_number is required.
Comment:/cancel-runsBot: Cancels all runs on the PR branch
Label:cancel-runsBot: Cancels all runs on the PR branch
MIT