Sub topic 10
Turning on debug logging
This chapter assumes you can read a workflow file, open a failed run, and find the failing step. Sometimes the normal log does not say enough. A step fails and the output shows a bare exit code. Debug logging adds detail from the runner and from actions, and you can switch it on without editing the workflow file.
What debug logging adds
GitHub Actions has two debug modes. Both are controlled by a variable or secret and take effect on the next run.
| Mode | Name | What it adds |
|---|---|---|
| Runner diagnostic logging | `ACTIONS_RUNNER_DEBUG` | Extra runner detail, and a downloadable diagnostic log archive |
| Step debug logging | `ACTIONS_STEP_DEBUG` | Extra messages from steps and actions, shown inline in the step log |
Step debug logging is the one you will use most. Lines that actions write with the ::debug:: workflow command appear in the log only when it is on. They are shown in a distinct color so you can tell them from normal output.
Ways to enable it
You can turn it on in three ways.
- Re-run with debug logging. In the run page, choose Re-run jobs, then tick Enable debug logging. This sets both modes for that one re-run only. It is the safest option because nothing persists.
- Use the gh CLI.
gh run rerun <run-id> --debugdoes the same thing from a terminal. - Set a repository secret or variable. Create
ACTIONS_STEP_DEBUGwith the valuetrue. Every later run then produces debug output until you remove it. Do the same withACTIONS_RUNNER_DEBUGfor runner diagnostics.
# Re-run only the failed jobs, with debug logging
gh run rerun <run-id> --failed --debug
# Then read the failed steps
gh run view <run-id> --log-failedThe --failed and --debug flags can be combined. You re-run only what broke, and you get the extra detail only where you need it.
Replace the placeholder above only if you need a diagram. The flow looks like this:
Writing your own debug lines
You can add ::debug:: messages to your own scripts. They cost nothing when debug logging is off.
steps:
- name: Build
run: |
echo "::debug::Working directory is $(pwd)"
echo "::debug::Node version is $(node --version)"
npm run buildIn a normal run these two lines do not appear. In a debug run they show up in the step log, which helps you confirm the environment without leaving permanent noise in the output.
What to look for
Debug output is long. Do not read it from the top. Start at the failing step you already found, then scan for these signs.
- Resolved values of inputs passed to an action, which show whether an expression produced what you expected.
- The paths an action searched, which explain "file not found" errors.
- Cache keys and whether a cache restore matched.
- Environment details such as the shell command line the runner used.
Cautions
Debug logs are more verbose, so they are more likely to expose sensitive values. Secrets are still masked, but derived values such as a transformed or partial secret may not be. Treat debug logs as sensitive, and avoid sharing them publicly.
Debug logging also does not fix anything by itself. It gives you evidence. Use it after you have read the normal log carefully and still lack a clear root cause.
Exercise
A step fails with only "Process completed with exit code 1" and the normal log gives no hint why. Which command re-runs only the failed jobs with extra diagnostic detail, and why is this better than creating an ACTIONSSTEPDEBUG secret for a one-off investigation?
Show answer
Run gh run rerun <run-id> --failed --debug. It re-runs only the failed jobs and enables debug logging for that re-run alone. A repository secret stays active for all workflows and runs until someone removes it, which increases log noise and the chance of exposing sensitive values.