nick-fields/retry
Retry a flaky command with a timeout, instead of re-running the whole job.
What it does
nick-fields/retry wraps a shell command with retry logic: it enforces a per-attempt timeout, waits between attempts, and only fails the step after max_attempts is exhausted.
It can retry on any failure, only on timeout, only on error, or only on a specific exit code, and can run a cleanup command between attempts.
Usage
workflow (.yml)
steps:
- uses: actions/checkout@v4
- uses: nick-fields/retry@v4
with:
timeout_minutes: 10
max_attempts: 3
command: npm run test:e2eInputs
| Input | Description | Default | Required |
|---|---|---|---|
command | The command to run. | - | Yes |
max_attempts | Number of attempts to make before failing the step. | 3 | Yes |
timeout_minutes | Minutes to wait before an attempt times out. Specify either minutes or seconds, not both. | - | No |
timeout_seconds | Seconds to wait before an attempt times out. Specify either minutes or seconds, not both. | - | No |
retry_wait_seconds | Seconds to wait before the next retry. | 10 | No |
retry_on | Event to retry on: any, timeout, or error. | - | No |
on_retry_command | Command to run before a retry (such as a cleanup script). | - | No |
Outputs
| Output | Description |
|---|---|
total_attempts | The final number of attempts made. |
exit_code | The final exit code returned by the command. |
exit_error | The final error returned by the command. |
Notes
A timeout is mandatory: set exactly one of timeout_minutes or timeout_seconds, or the action fails before running the command.
Retrying masks flakiness rather than fixing it, pair it with a test reporter so retried failures stay visible.
Common errors
Must specify either timeout_minutes or timeout_seconds inputsmeans neither timeout was set. One of the two is required.Final attempt failedmeans the command failed on every attempt; the step then exits with the command's exit code. Check the log of the last attempt, not the first.
Security and pinning
- The
commandruns with the job's full environment and token. Never interpolate untrusted input (PR titles, issue bodies) into it, and pin the action to a commit SHA.
Alternatives and related
cypress-io/github-actionRun Cypress end-to-end and component tests with dependency install and caching handled for you.
dorny/test-reporterTurn test result files (JUnit, TRX, JSON) into a GitHub check run with annotations.
Frequently asked questions
Can this retry a whole job or another action?
No. It retries a single shell command. To retry a
uses: step or an entire job you need to re-run the job or restructure the logic into a command this action can wrap.