Skip to content
Latchkey

How to Implement /retest and /rerun-failed in GitHub Actions

/retest re-runs the whole workflow while /rerun-failed re-runs only the jobs that failed, both from a PR comment.

On a /retest or /rerun-failed comment, resolve the latest run for the PR head SHA and call gh run rerun, adding --failed for the failed-only variant.

Steps

  • Match /retest or /rerun-failed on the comment.
  • Find the latest run id for the PR head SHA.
  • Run gh run rerun <id> or add --failed.

Terminal

Terminal
# resolve the latest run for the PR head sha
RUN_ID=$(gh run list --branch "$HEAD_BRANCH" --limit 1 --json databaseId --jq '.[0].databaseId')

# /retest: re-run everything
gh run rerun "$RUN_ID"

# /rerun-failed: re-run only failed jobs
gh run rerun "$RUN_ID" --failed

Gotchas

  • gh run rerun --failed only re-runs failed jobs plus their dependents, saving minutes.
  • A re-run keeps the original run id and appends an attempt, so history stays linked.
  • Latchkey auto-retries transient failures on managed runners, cutting how often /retest is needed.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →