How to see the failed attempt after you re-run a GitHub Actions job
You re-ran a failed job, it turned green, and the red attempt seems to have vanished from the page. It hasn't. On the run's page, open the Latest dropdown to the right of the run name and click a previous run attempt. From a terminal, gh run view takes an --attempt flag, and the REST API has endpoints for a single attempt and its logs.
Below is how to find each one. After that: why a downloaded log archive can be missing jobs, and what the failed attempt can tell you before you merge.
Why the failed attempt seems to disappear
A re-run doesn't give you a new run. GitHub's contexts reference says of github.run_id: "This number does not change if you re-run the workflow run." What changes is the attempt number.
github.run_attempt is described as "A unique number for each attempt of a particular workflow run in a repository." It increments with each re-run. In short: same run, new attempt. The older attempts are one dropdown away.
The re-run also uses the same commit. GitHub's re-run docs say the workflow will use the same GITHUB_SHA (commit SHA). So a red attempt and a green attempt in one run are two tries at the same commit. Keep that in mind, because it's the part that matters later.
Open an earlier attempt in the browser
- In the left sidebar, click the workflow you want to see, then open the run.
- To the right of the run name, select the Latest dropdown menu and click a previous run attempt.
- Under Jobs or in the visualization graph, click the job you want to see. You're now looking at that job from the attempt you picked.
- Expand the step that failed before you search. GitHub's log docs say: "When you search logs, only expanded steps are included in the results." This one is easy to miss. A search that finds nothing may mean the step is collapsed, not that the text isn't there.
Here's what to check first: switch between the failed attempt and the latest one, and compare the failing step side by side. If the error text is a timeout, a network error or a race in a test you didn't touch, that's a different story from an assertion in code your pull request changed.
Download the full set of logs after a partial re-run
Here's the catch with re-running only some jobs. GitHub's log docs say: "When you download the log archive for a workflow that was partially re-run, the archive only includes the jobs that were re-run." The jobs that weren't re-run aren't in it.
That follows from how partial re-runs work. When you re-run failed jobs or a specific job, GitHub also re-runs the jobs that depend on them. The jobs left out keep their outputs from the previous attempt, which the newly run jobs can use. They don't run again, so they have no new log.
To get everything, the docs say you must download the log archives for the previous run attempts that ran the other jobs. In practice:
- Use the Latest dropdown to switch to the earlier attempt.
- Open a job's log. In the upper right corner of the log, select the dropdown menu, then click Download log archive.
- Repeat for each attempt you need, and keep the archives apart so you know which attempt each one came from.
Earlier attempts from the GitHub CLI
The gh run view manual has an example for exactly this:
gh run view 12345 --attempt 3| Flag | What the manual says |
|---|---|
| --attempt | The attempt number of the workflow run |
| --log | View full log for either a run or specific job |
| --log-failed | View the log for any failed steps in a run or specific job |
| --job | View a specific job ID from a run |
For one job's full log, the manual gives this example:
gh run view --log --job 456789Earlier attempts from the REST API
If you script this, the workflow runs API has an endpoint for one attempt and one for that attempt's logs. The attempt_number parameter is described as "The attempt number of the workflow run."
/repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}
/repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs- Get a workflow run attempt: "Gets a specific workflow run attempt."
- Download workflow run attempt logs: "Gets a redirect URL to download an archive of log files for a specific workflow run attempt." The docs add: "This link expires after 1 minute." Follow the redirect right away instead of storing it.
- List jobs for a workflow run attempt: "Lists jobs for a specific workflow run attempt."
- Listing jobs for a whole run instead? Its latest filter returns jobs from the most recent execution of the workflow run. If your script sees only green jobs, check that filter first.
What the failed attempt tells you
Once you can see both attempts, you have a useful fact: this job failed and then passed on the same commit. Treat that as a hint the job may be flaky. It isn't proof the failure is harmless. Read the failed step's log, and if the error touches code your pull request changed, treat it as real.
One time is a hint. A pattern across many commits is stronger evidence. Checking that by hand means opening attempt after attempt on run after run. If you want that count on the pull request itself, we make FlakeRadar, a free Chrome extension. It reads the repository's own GitHub Actions history and counts a job as flaky when it failed and then passed on the same commit. Each failing check gets a label (Known flake, New failure, Also failing on the default branch, or Not enough history) with counts, a time window and a date. It only analyses GitHub Actions checks, and a Known flake label is evidence, not a promise.
Limits to know before you re-run again
- Time: you can re-run a workflow run, its failed jobs or a specific job up to 30 days after its initial run.
- Count: "A workflow run can be re-run a maximum of 50 times." That limit includes both full re-runs and re-runs of a subset of jobs.
- Same code: a re-run uses the same commit SHA, so re-running won't pick up a fix you pushed since. Push the fix and let the new commit's checks run.
Sources
- GitHub Docs guide to re-running workflows and jobs
- GitHub Docs guide to using workflow run logs
- GitHub Actions contexts reference (github.run_id and run_attempt)
- GitHub CLI manual for gh run view
- REST API reference for workflow runs
- REST API reference for workflow jobs
Questions
Does re-running a job delete the failed attempt?
No. The earlier attempt stays on the run. To the right of the run name, select the Latest dropdown menu and click a previous run attempt.
Does a re-run test the same commit?
Yes. GitHub's re-run docs say the workflow uses the same GITHUB_SHA (commit SHA). To test a fix you pushed, let the new commit's checks run.
Why is my downloaded log archive missing jobs?
When you download the log archive for a workflow that was partially re-run, the archive only includes the jobs that were re-run. Switch to the earlier attempt and download its archive too.
Can a workflow tell which attempt it is on?
Yes. Read github.run_attempt. It increments with each re-run, while github.run_id stays the same.
Related
- Fine-grained token permissions to read GitHub Actions runs (and re-run them)
- Is a failing GitHub Actions check flaky or real? How to read the run history before you re-run
- How to re-run a failed GitHub Actions job with debug logging (web and gh CLI)
- Is the failing check on your PR also broken on main? How to check the default branch first