Sub topic 12
A practical failure-triage routine
This chapter ties the earlier ones together into one routine. It assumes you know how run attempts work, the three re-run scopes, and the difference between step debug logs and runner diagnostic logs. It also assumes basic gh CLI use.
The goal of triage
A red run has one of three causes: your code, the environment, or a flaky dependency. Triage decides which one as cheaply as possible. Start with the least invasive action and escalate only when the evidence requires it.
Step 1: Read the failed logs first
Do not re-run before reading. A re-run creates a new attempt, and you lose nothing by reading first, but you lose time by guessing.
gh run list --workflow ci.yml --status failure --limit 5
gh run view 1234567890 --log-failedLook for the first error, not the last. Later errors are often side effects of the first one. If the message names a missing file, a bad exit code, or a failed assertion, the cause is probably in your code. Fix it and push.
Step 2: Re-run only what failed
If the logs are ambiguous, for example a network timeout or a runner that lost connection, re-run the failed jobs.
gh run rerun 1234567890 --failedThis keeps the same commit and the same event payload, so a pass on attempt 2 tells you the code did not change the outcome. Jobs that already succeeded are reused, which saves time and runner minutes. If one job is the suspect, gh run rerun --job 987654321 limits the attempt further.
A pass on re-run does not mean the problem is gone. Record it as a flaky failure, with the run ID and the step that failed, so a pattern becomes visible.
Step 3: Re-run with debug logging
If the same step fails again with no clear reason, ask for more detail on that one re-run.
gh run rerun 1234567890 --failed --debugIn the web interface, the same option is the Enable debug logging checkbox in the re-run dialog. Debug logging applies only to that attempt, so you do not change repository settings for a one-off problem.
Read the output in this order:
- Step debug lines, which start with
##[debug], show expanded inputs, conditions, and the evaluation ofif:expressions. - Runner diagnostic logs, included in the downloaded log archive, show runner setup and job-level behavior.
If you need debug output on every run, for example while chasing an intermittent failure, set ACTIONS_STEP_DEBUG and ACTIONS_RUNNER_DEBUG. Then remove them when you are done.
Step 4: Add targeted diagnostics
When debug logs show too much or too little, put the diagnostics where you need them. A step with ::debug:: appears only when step debug logging is on. A step guarded by runner.debug runs only in debug mode.
name: ci
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Show attempt number and emit a debug message
run: |
echo "attempt=${{ github.run_attempt }} triggering_actor=${{ github.triggering_actor }}"
echo "::debug::Shown only when step debug logging is enabled"
- name: Extra diagnostics only in debug mode
if: ${{ runner.debug == '1' }}
run: env | sort | grep '^GITHUB_'Printing github.run_attempt makes it clear in the logs which attempt you are reading.
Step 5: Treat debug logs as sensitive
Debug logs are more verbose, so they can show more than you intended. Secrets are still masked, but values derived from them, such as a decoded or transformed token, may not be. Before sharing a log or attaching it to an issue:
- Search it for tokens, URLs with credentials, and internal host names.
- Prefer sharing the relevant excerpt over the whole archive.
- Do not leave persistent debug settings in place after the investigation.
Verbose logs are also noisy. Searching for the first ##[error] line, then reading upward, usually finds the cause faster than reading from the top.
The routine at a glance
| Step | Action | Escalate when |
|---|---|---|
| 1 | Read `--log-failed` | The cause is unclear |
| 2 | Re-run failed jobs | It fails again |
| 3 | Re-run with debug logging | Debug logs show the cause |
| 4 | Add `::debug::` or `runner.debug` steps | Existing output is not enough |
| 5 | Review and clean up | Always |
Exercise
A job fails with a timeout. You re-run the failed jobs and it passes. What should you do next, and why not just close the matter?
Show answer
Record the run ID and failing step as a flaky failure and look for a pattern in later runs. A pass on re-run uses the same commit, so it points to an environment or dependency cause, not a fixed bug. If it keeps recurring, re-run with debug logging to collect more evidence.
Exercise
You enabled ACTIONSSTEPDEBUG as a secret to chase an intermittent failure, and you found the cause. What cleanup do you do, and why?
Show answer
Delete the ACTIONSSTEPDEBUG secret, and ACTIONSRUNNERDEBUG if you set it. Otherwise every later run keeps producing verbose logs, which are noisy and may expose values derived from secrets.