# gh workflow enable and disable in CI

> gh workflow enable and gh workflow disable toggle whether a workflow runs. Reference for selecting by name or ID and the permission errors seen in CI.

Source: https://latchkey.dev/learn/command-reference/gh-workflow-enable-disable  
Updated: 2026-06-30

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.

## Common usage

```Terminal
gh workflow disable nightly.yml
gh workflow enable nightly.yml
gh workflow disable 161335 -R owner/repo
```

## Flags

| Argument | What it does |
| --- | --- |
| <workflow> | Workflow name, filename, or numeric ID |
| -R, --repo <owner/repo> | Target a specific repository |

## 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.

## 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@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached
```

> `git rev-parse --abbrev-ref HEAD` returns the literal string `HEAD` on a detached checkout rather than a branch name. On GitHub Actions read `github.ref_name` instead; the git command cannot know what it was checked out for.

## FAQ

### 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.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
