Skip to content
LatchkeyLatchkey home

gh run rerun: Re-run Failed Workflow Jobs

gh run rerun re-runs a workflow run, either entirely or just the jobs that failed.

For flaky-test recovery, gh run rerun --failed retries only what broke instead of burning minutes on the whole matrix.

What it does

gh run rerun starts a new attempt of a workflow run. By default it re-runs all jobs; --failed re-runs only the failed ones, and --job re-runs a single job. --debug enables step debug logging for the new attempt.

Common usage

Terminal
gh run rerun 1234567890
gh run rerun 1234567890 --failed
gh run rerun --job 9876543210
gh run rerun 1234567890 --failed --debug

Flags

FlagWhat it does
--failedRe-run only the failed jobs
-j, --job <job-id>Re-run a specific job by ID
-d, --debugEnable step debug logging for the new run
<run-id>The workflow run to re-run
-R, --repo <owner/repo>Target a specific repository

In CI

Set GH_TOKEN and permissions: { actions: write }. Only the most recent attempt of a run can be re-run, and re-running consumes a new set of Actions minutes. --debug requires the token to have access to enable debug logging.

Common errors in CI

"Resource not accessible by integration" or "HTTP 403" means the token lacks actions: write. "run ... cannot be rerun; its workflow file may be broken" means the workflow file at that commit no longer parses. Re-running an old attempt fails because only the latest attempt is eligible.

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

Frequently asked questions

gh run rerun: Re-run Failed Workflow Jobs?
For flaky-test recovery, gh run rerun --failed retries only what broke instead of burning minutes on the whole matrix.
What it does?
gh run rerun starts a new attempt of a workflow run. By default it re-runs all jobs; --failed re-runs only the failed ones, and --job re-runs a single job. --debug enables step debug logging for the new attempt.
In CI?
Set GH_TOKEN and permissions: { actions: write }. Only the most recent attempt of a run can be re-run, and re-running consumes a new set of Actions minutes. --debug requires the token to have access to enable debug logging.
Common errors in CI?
"Resource not accessible by integration" or "HTTP 403" means the token lacks actions: write. "run ... cannot be rerun; its workflow file may be broken" means the workflow file at that commit no longer parses. Re-running an old attempt fails because only the latest attempt is eligible.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card