Sub topic 3
What a re-run reuses, what changes, and its limits
This chapter assumes you know what a workflow run and a run attempt are, and that you can read a workflow YAML file. A re-run is not a fresh trigger. It repeats an existing run, so some things stay fixed and others can differ.
What stays the same
A re-run keeps the identity of the original run. It does not check out the newest code on the branch.
- Commit and ref.
GITHUB_SHAandGITHUB_REFmatch the original event. If someone pushed new commits after the failure, the re-run still builds the old commit. - Workflow file. The workflow file is the version at that commit. Fixing the YAML on the branch afterward does not change a re-run of the old run.
- Event payload. The same event data applies, including
workflow_dispatchinputs. - Run identity.
github.run_idandgithub.run_numberstay the same. - Outputs and artifacts of successful jobs. When you re-run only failed jobs, jobs that depend on them can still use the outputs and artifacts from the successful jobs of the earlier attempt.
What changes
| Value | On a re-run |
|---|---|
| `github.run_attempt` | Increases by 1 for each re-run |
| `github.triggering_actor` | The user who clicked re-run |
| `github.actor` | Stays the user who started the original run |
| Job logs | A new set per attempt. Earlier attempts stay viewable |
| Outside world | Whatever is current: external services, moving tags, runner images |
The last row causes most surprises. uses: actions/checkout@v4 points at a tag that can move. A package registry may have published a new version. A runner image may have been updated. A re-run can therefore pass or fail for reasons unrelated to your code.
The distinction between actor and triggering_actor matters for permissions. A re-run uses the privileges of github.actor, even if the person who triggered the re-run has different privileges. Re-running does not give you the permissions of the person who clicked the button.
Seeing the difference in a workflow
This workflow prints the values that tell attempts apart.
name: attempt-info
on: [push]
jobs:
info:
runs-on: ubuntu-latest
steps:
- name: Print run identity
run: |
echo "run_id=${{ github.run_id }}"
echo "run_number=${{ github.run_number }}"
echo "run_attempt=${{ github.run_attempt }}"
echo "sha=${{ github.sha }}"
echo "actor=${{ github.actor }}"
echo "triggering_actor=${{ github.triggering_actor }}"Push once, then re-run it from another account or after pushing a second commit. In the second attempt, run_id, run_number, sha, and actor are unchanged. run_attempt is 2, and triggering_actor is the person who clicked re-run.
Limits
- Age. You can re-run a workflow run only within 30 days of the original run.
- Logs. A run whose logs have been deleted cannot be re-run. Log retention is configurable and defaults to 90 days, so the 30-day re-run limit usually applies first.
- Completion. Failed-job and single-job re-runs require the run to have finished. You cannot re-run part of a run that is still in progress.
- Dependents. Re-running a failed job also re-runs the jobs that depend on it through
needs. Those jobs were skipped in the failed attempt. - Cost. Each re-run uses runner minutes like any other run.
- Concurrency. A re-run is subject to the same
concurrencygroup rules as the original. It can be queued or can cancel another run.
Common errors
- Expecting a pushed fix to be picked up by "Re-run all jobs". It will not be.
- Treating a pass on attempt 2 as proof the code is correct. A moving tag or a flaky external service may have changed in between.
- Assuming
github.actorshows who re-ran the workflow. Usegithub.triggering_actor. - Trying to re-run a run older than 30 days and wondering why the option is missing.
Exercise
A build failed on commit abc123. You then pushed commit def456 to the same branch, which fixes the bug. You click "Re-run failed jobs" on the original run. Which commit does attempt 2 build, what is github.run_attempt, and what should you do to test your fix?
Show answer
Attempt 2 builds abc123, because a re-run keeps the original GITHUB_SHA and the original workflow file. github.run_attempt is 2. To test the fix, use the run that the push of def456 created, or push a new commit, so a new run starts on the new code.