Your scheduled job stopped running weeks ago and nobody noticed: gh workflow enable puts a disabled GitHub Actions workflow back to active. You will finish with the workflow restored and a check that you changed the intended repository. This guide uses GitHub CLI 2.87.3, installed from the gh package on this machine. Allow about five minutes if you already know the repository and workflow name.
The command changes remote repository state. You need an authenticated gh session and permission to administer Actions in the repository. No root access is needed, and you should not use sudo for this task.
Make the repository explicit with --repo before enabling anything. The value accepts OWNER/REPO, or HOST/OWNER/REPO for a GitHub Enterprise host:
$ gh workflow list --all --repo EXAMPLE_OWNER/EXAMPLE_REPO --limit 50
Replace both uppercase placeholders with the repository you intend to change. The --all flag matters: ordinary listing hides disabled workflows, so leaving it out can make the workflow you need look missing.
Expected output is a table with columns such as Name, State and ID. Find the workflow whose state is disabled, then record its displayed name or numeric ID. You can also select it later by workflow file name, such as nightly.yml.
Checkpoint: If the list names the wrong organisation, repository or host, stop and correct --repo. Do not rely on whichever repository the surrounding shell directory happens to imply.
Use the workflow's exact displayed name, ID or file name. A name containing spaces must be quoted:
$ gh workflow view "Nightly maintenance" --repo EXAMPLE_OWNER/EXAMPLE_REPO
If you have the file name instead, use it as the selector:
$ gh workflow view nightly.yml --repo EXAMPLE_OWNER/EXAMPLE_REPO
These checks are read-only. They catch a similar name or a typo before the write. gh workflow enable accepts one optional selector. Leave it out and GitHub CLI opens an interactive choice when it has a usable terminal: handy for exploring, a poor fit for a script or a pasted runbook.
Run the command with the selector you confirmed:
$ gh workflow enable "Nightly maintenance" --repo EXAMPLE_OWNER/EXAMPLE_REPO
You can substitute the numeric ID:
$ gh workflow enable 123456789 --repo EXAMPLE_OWNER/EXAMPLE_REPO
On success, GitHub CLI normally prints nothing and exits with status 0. Underneath, it sends an enable request that sets the workflow state to active. A successful enable does not start a run, edit the workflow YAML or change its triggers.
Tip: In a shell script, capture the status immediately:
if gh workflow enable "Nightly maintenance" --repo EXAMPLE_OWNER/EXAMPLE_REPO; then
printf '%s\n' 'Workflow enabled'
else
status=$?
printf 'Enable failed with status %s\n' "$status" >&2
exit "$status"
fi
List workflows again, still including disabled entries, and inspect the target row:
$ gh workflow list --all --repo EXAMPLE_OWNER/EXAMPLE_REPO --limit 50
The workflow should now show an active state and stay visible in the list. For a less fragile check, ask for machine-readable fields:
$ gh workflow list --all --repo EXAMPLE_OWNER/EXAMPLE_REPO --json id,name,path,state --limit 50
Look for the matching id, name or path and confirm state is active. The JSON ordering is not a contract, so scripts should select fields by name rather than matching the whole line.
gh workflow list says so, pass --repo OWNER/REPO explicitly. That also avoids acting on a repository inferred from a local checkout.--all and check the selector, repository owner and filename.gh auth workflow, then make sure that account can administer Actions in the repository. Enabling a workflow needs write permission for Actions through GitHub's API.workflow_dispatch trigger and use the separate gh workflow run command. That is another state-changing action and is outside this guide.If you enabled the wrong workflow, reverse it with the matching selector and repository:
$ gh workflow disable "Nightly maintenance" --repo EXAMPLE_OWNER/EXAMPLE_REPO
This stops the workflow running and hides it from the default list. Verify the result with gh workflow list --all.
Safety boundary: Disabling does not delete the workflow file, but it can stop scheduled or event-driven runs. Use it only when that interruption is intentional.
gh workflow enable returned status 0.active.