gh workflow enable and gh workflow disable turn a workflow on or off so it stops or resumes triggering.
During incidents or migrations you sometimes need to pause a noisy workflow; these two commands flip its state without editing the file.
What it does
gh workflow disable stops a workflow from being triggered by any event while leaving the file in place; gh workflow enable re-activates it. Both accept a workflow name, filename, or ID, or prompt interactively.
Set GH_TOKEN and permissions: { actions: write }. Pass the workflow by filename so the command is deterministic on a headless runner; without an argument it tries to prompt. A disabled workflow ignores all events, including schedule and workflow_dispatch.
Common errors in CI
"Resource not accessible by integration" or "HTTP 403" means the token lacks actions: write. "could not find any workflows named X" means the identifier is wrong; check gh workflow list. Disabling an already-disabled workflow is a no-op rather than an error.
Using this in CI
CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.
.github/workflows/ci.yml
- uses:actions/checkout@v4with:fetch-depth:0 # history, tags, and git describe all need this- run:|git rev-parse --is-shallow-repository # expect falsegit rev-parse --abbrev-ref HEAD # prints HEAD when detached
Frequently asked questions
gh workflow enable and disable in CI?
During incidents or migrations you sometimes need to pause a noisy workflow; these two commands flip its state without editing the file.
What it does?
gh workflow disable stops a workflow from being triggered by any event while leaving the file in place; gh workflow enable re-activates it. Both accept a workflow name, filename, or ID, or prompt interactively.
In CI?
Set GH_TOKEN and permissions: { actions: write }. Pass the workflow by filename so the command is deterministic on a headless runner; without an argument it tries to prompt. A disabled workflow ignores all events, including schedule and workflow_dispatch.
Common errors in CI?
"Resource not accessible by integration" or "HTTP 403" means the token lacks actions: write. "could not find any workflows named X" means the identifier is wrong; check gh workflow list. Disabling an already-disabled workflow is a no-op rather than an error.