MSBA-300 · Lesson 10 of 12 · 19 min
Workflow logs and debugging
▶ Video coming soon A video version of this lesson is on the way.
The tenth clinic was the one Lena had been waiting for. Priya brought a list of five failed runs from the past month, printed out, and said the session would not be about writing workflows at all, but about reading them after the fact. "Writing a workflow is maybe a third of the work," she said. "The rest is working out why it did what it did." This lesson covers where the evidence of a run lives, how to get more of it when the default logs are not enough, and how to make your own workflows leave better evidence. Lesson 11 then applies all of it to the common causes of failure.
Where the evidence is
Every run has a summary page, reached from the Actions tab or from a check on a pull request. It shows the trigger, the commit, the actor and the total duration; a graph of jobs with their dependencies and status; any annotations, which are errors, warnings and notices that jobs raised, often linked to a file and line; any job summaries that steps wrote; and the run's artifacts. For most failures, the summary page alone tells you which job failed and often why.
Opening a job shows its log: one collapsible section per step, including setup steps that GitHub adds, such as Set up job, which records the runner image, its version and the permissions of the GITHUB_TOKEN, and Complete job, which records clean-up. Lines are numbered and timestamped, and each line has a link you can share with a colleague. A search box finds text across the job's log. The Set up job section answers a surprising number of questions on its own, because it shows which image version ran, which actions were downloaded at which commit, and which permissions the token had.
| Where | What you learn | Typical question it answers |
|---|---|---|
| Run summary | Trigger, actor, commit, job graph, annotations, artifacts | Which job failed, and was this the event I expected? |
| Set up job | Runner image and version, token permissions, actions downloaded | Did the image change? What could the token do? |
| Step log | Commands run and their output, exit code | What exactly failed, and with what message? |
| Job summary | Markdown the workflow wrote, such as test results | How many tests failed and which ones? |
| Artifacts | Files the run saved, such as reports and screenshots | What did the build actually produce? |
| Run history | Earlier runs of the same workflow | When did this start failing, and what changed then? |
Run history and comparing runs
One run tells you what happened; the history tells you when it started. The Actions tab filters runs by workflow, branch, event, status and actor. When a workflow that passed yesterday fails today, find the last green run and the first red one, then compare: the commit range, the runner image version in Set up job, the action versions downloaded and the timing. If nothing in the repository changed between them, the cause is outside it, such as a new runner image, a new release of an action or tool that was not pinned, or an external service.
Downloading logs and working from the command line
Logs can be downloaded as a zip file from the run page, either for one job or for the whole run. The GitHub CLI makes the same information easy to reach from a terminal: gh run list shows recent runs, gh run view shows a run's jobs and, with the right flags, the log of a failed step, and gh run watch follows a run in progress. The REST API offers endpoints to list workflow runs and jobs, download logs, re-run jobs, cancel runs and delete old logs, which teams use for dashboards and housekeeping. The GH-200 outline expects you to know that workflows, logs and artifacts can be located both in the user interface and through the API.
# The last few runs of the check workflow on main
gh run list --workflow check.yml --branch main --limit 5
# Show the jobs of one run, then only the failed steps' logs
gh run view 4211
gh run view 4211 --log-failed
# Follow a run in progress
gh run watch 4215
# Re-run only the failed jobs, with debug logging
gh run rerun 4211 --failed --debugReading a log well
Logs reward a method. Start at the failed step, then scroll up from its last line until you reach the first message that looks like a real error, because tools often print a cascade of follow-on errors after the first one. Read the command that was run, which the log shows just before its output, and check that it is the command you think it is, with the arguments and working directory you expect. Check the exit code that ended the step: an exit code of 1 is a normal failure, while codes such as 127 (command not found) or 137 (the process was killed, often for running out of memory) point at the environment rather than the code.
Timing is evidence too. The timestamps on log lines show where the time went, and a step that usually takes ten seconds but took ten minutes before failing points at a network timeout or a resource limit. The run summary shows the duration of each job, and comparing it with earlier runs reveals slow drifts, such as a cache that stopped working or a test suite that grew, long before they become failures.
2026-11-02T14:03:11Z Run npm ci
2026-11-02T14:03:11Z npm ci
2026-11-02T14:03:11Z shell: /usr/bin/bash -e {0}
2026-11-02T14:03:19Z npm error code EBADENGINE
2026-11-02T14:03:19Z npm error engine Unsupported engine
2026-11-02T14:03:19Z npm error notsup Required: {"node":">=24"}
2026-11-02T14:03:19Z npm error notsup Actual: {"npm":"10.9.2","node":"v22.11.0"}
2026-11-02T14:03:19Z Error: Process completed with exit code 1.The excerpt shows the method at work. The command and its shell are printed first; the first npm error line names the problem precisely; and the final line only reports the exit code. Someone who reads only the last line learns that the step failed. Someone who reads the first error learns that a matrix value or a setup step installed the wrong Node version, which is something they can fix in a minute.
How long logs are kept
Logs follow the same retention settings as artifacts, 90 days by default and adjustable by administrators. People with write access can delete the logs of a run from the run page, for example after a secret was accidentally printed, and whole runs can be deleted as well. Deleting logs does not undo exposure: if a credential appeared in a log, rotate it first, then delete the logs.
Getting more detail: debug logging
When the normal log does not explain a failure, ask GitHub for more. There are two kinds of extra logging. Step debug logging makes actions and steps print debug messages that are normally hidden, such as the exact parameters an action received or the cache keys it tried. Runner diagnostic logging adds the runner application's own diagnostic files, useful for problems with the runner itself, such as a job that never starts its first step.
The quickest way to get both for a failed run is the Re-run jobs menu on the run page, which offers an option to enable debug logging for that re-run only. To turn them on for every run, set a repository secret or variable named ACTIONS_STEP_DEBUG to true for step debug logging, and ACTIONS_RUNNER_DEBUG to true for runner diagnostic logging. Debug logs are verbose and may show more about your environment than usual, so switch the permanent settings off again once the problem is solved.
Worked problem
The cache that never hit
The check workflow restores its npm cache on every run but always reports a miss, even though the lock file has not changed for weeks. The log just says "Cache not found for input keys". How do you find out why?
Show solution
- Re-run the job with debug logging enabled from the Re-run jobs menu.
- In the debug output, the cache action prints the exact key it computed and the restore keys it tried.
- Comparing two runs shows the key changing every time because it includes the run number, which a well-meaning edit had added.
- Remove the run number from the key so it depends only on the operating system and the lock file hash.
Answer: Debug logging reveals the computed key; it changed on every run because it contained the run number. Key on the OS and lock file hash only.
Making your workflow leave better evidence
Good workflows explain themselves. GitHub provides workflow commands, special lines a step prints to standard output, that the runner turns into structure in the log and annotations on the run. The GH-200 outline lists using workflow commands both in workflows and inside actions.
| Command (printed by a step) | Effect |
|---|---|
| ::group::Title and ::endgroup:: | Folds the lines between them into a collapsible section in the log |
| ::notice file=...,line=...::message | Creates a notice annotation, optionally attached to a file and line |
| ::warning file=...,line=...::message | Creates a warning annotation |
| ::error file=...,line=...::message | Creates an error annotation, shown on the run and in the pull request files view |
| ::add-mask::value | Hides that value in the rest of the job's logs |
| ::debug::message | Prints only when step debug logging is enabled |
- name: Validate trail reports
run: |
echo "::group::Validator version and settings"
node validator/cli.js --version
cat validator/config.json
echo "::endgroup::"
if ! node validator/cli.js reports/*.json > results.txt; then
echo "::error file=reports/fundy.json,line=12::Missing closure end date"
exit 1
fi
echo "::notice::All reports valid"Annotations are especially useful on pull requests, because an error attached to a file and line appears in the Files changed view next to the line, where the author will see it. Many linters and test tools can emit annotations directly, or through a problem matcher, which turns lines matching a pattern in tool output into annotations without changing the tool.
Job summaries
Each step can append Markdown to the file named by GITHUB_STEP_SUMMARY. Everything written there appears as the job summary on the run page, in a readable form: headings, tables, lists, links and short code blocks. A test job can write a table of passed and failed tests; a build job can list the files it produced and their sizes; a deploy job can link to the deployed page. Summaries are limited in size per step, so they suit concise reports rather than whole logs.
- name: Write a summary
if: always()
run: |
{
echo "## Trail report validation"
echo ""
echo "| Region | Reports | Errors |"
echo "|---|---|---|"
echo "| Fundy | 42 | 1 |"
echo "| Acadian coast | 37 | 0 |"
} >> "$GITHUB_STEP_SUMMARY"Capturing evidence on failure
Some evidence only matters when something goes wrong: a full log from a tool, screenshots from a browser test, the generated configuration. Steps with the condition failure() can collect and upload these as artifacts only on failed runs, keeping storage low on green runs. Combined with an always() summary step, that gives every failed run a short human-readable explanation and the raw files to dig into.
Watching trends, not just failures
Individual runs explain individual problems; trends show where a workflow is heading. GitHub provides Actions usage metrics and performance metrics for organizations, which show minutes used, job durations, queue times and failure rates by workflow, repository and runner type. Even without them, the run history of a single workflow shows whether durations are creeping up or failures are becoming more frequent. Tidewater looked at the numbers once a month, which was enough to catch the slow cache before Rosa's budget alert did. A workflow whose average duration doubles over a few weeks usually has a cause worth finding, such as a cache that stopped hitting, a dependency that grew, or a test suite that started waiting on a network service.
Getting help from Copilot
GitHub Copilot can explain a failed Actions job from the run page: it reads the log and suggests what went wrong and how to fix it. It is a quick first opinion, particularly for unfamiliar error messages, but it reads the same log you do, so it cannot see causes that leave no trace in the log, and its suggestions deserve the same review as any other change.
Common mistakes
MistakeScrolling only to the last line of a long log.
InsteadFind the first error; later lines are often consequences of it.
MistakeLeaving ACTIONS_STEP_DEBUG on permanently.
InsteadEnable debug logging for a re-run, or temporarily, then turn it off.
MistakeIgnoring the Set up job section.
InsteadIt shows the runner image version, actions downloaded and token permissions, which explain many failures.
MistakePrinting huge amounts of output to the job summary.
InsteadKeep summaries concise and upload full reports as artifacts.
At the end of the session Lena went through Priya's five failed runs on her own. She explained four of them from the summary page and the Set up job section alone; the fifth needed debug logging and turned out to be the cache key problem from the example above.
Summary and key terms
- The run summary shows the trigger, job graph, annotations, job summaries and artifacts; job logs show each step.
- Set up job records the runner image, action versions and token permissions.
- Compare the last green and first red runs to find what changed, inside or outside the repository.
- Logs, runs and artifacts are available through downloads, the GitHub CLI and the REST API.
- Debug logging comes from a re-run option or the ACTIONS_STEP_DEBUG and ACTIONS_RUNNER_DEBUG settings.
- Workflow commands, annotations, job summaries and failure-only artifacts make runs explain themselves.
- Run summary
- The page for a workflow run showing its jobs, annotations, summaries and artifacts.
- Annotation
- An error, warning or notice raised by a job, optionally linked to a file and line.
- Job summary
- Markdown written to GITHUB_STEP_SUMMARY and shown on the run page.
- Workflow command
- A specially formatted line printed by a step that the runner acts on.
- Step debug logging
- Extra debug output from actions and steps, enabled per re-run or with ACTIONS_STEP_DEBUG.
- Runner diagnostic logging
- Additional runner log files, enabled with ACTIONS_RUNNER_DEBUG.
- Problem matcher
- A pattern that turns matching lines of tool output into annotations.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Where would you check which runner image version a job used?
Show answer
In the Set up job section of the job log.
How do you enable debug logging for one re-run only?
Show answer
Use the Re-run jobs option to enable debug logging, or gh run rerun with --debug.
Which file do steps write to for the job summary?
Show answer
The file named by GITHUB_STEP_SUMMARY.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.