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
/retestor/rerun-failedon 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" --failedGotchas
gh run rerun --failedonly 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
How to Run gh workflow run From Chat for GitHub ActionsRun gh workflow run from a chat command handler to start a workflow_dispatch in GitHub Actions, passing typed…
How to Rate Limit Chat Commands in GitHub ActionsRate limit chat-triggered commands in GitHub Actions with a concurrency group so a flood of /deploy comments…