gh run cancel: Stop a Workflow Run in CI
gh run cancel requests cancellation of a running GitHub Actions workflow run.
Concurrency guards and superseded-build logic call gh run cancel to halt obsolete runs and free up runners.
What it does
gh run cancel sends a cancellation request for a workflow run by ID, or prompts to pick a run when none is given. Cancellation is asynchronous: the run moves to cancelling, then cancelled once jobs stop.
Common usage
gh run cancel 1234567890
gh run cancel 1234567890 -R owner/repoFlags
| Flag | What it does |
|---|---|
| <run-id> | The workflow run to cancel |
| -R, --repo <owner/repo> | Target a specific repository |
In CI
Set GH_TOKEN and permissions: { actions: write }. Pass an explicit run ID since the interactive picker cannot run headless. Cancellation is best-effort and may take a moment to take effect, so do not assume the run is stopped the instant the command returns.
Common errors in CI
"Resource not accessible by integration" or "HTTP 403" means the token lacks actions: write. "cannot cancel a workflow run that is completed" means the run already finished. A bare gh run cancel with no ID on a headless runner fails because the picker needs a terminal.