Skip to content

DevOps Operations / Continuous integration · Step 5 of 7

Lesson: Workflow LogsSwitch
← DevOps Operations

Delivery and containers

Workflow Logs

Read CI logs to find the first real error, using the web page or the GitHub CLI.

When a run turns red, the log is your evidence. Reading it well saves hours of guessing.

Finding your way

On GitHub, open the Actions tab, pick a run, then a job, then a step. Each step has its own folded section with the command and its output.

With the GitHub CLI (gh), after signing in with gh auth login:

bash
gh run list --limit 3
gh run view 1234567890
gh run view 1234567890 --log-failed

run list shows recent runs and their IDs. run view summarises one run. --log-failed prints only the log of failed steps, and --log prints the full log. Use your own run ID.

Read from the first error

A failed step often ends like this:

Run npm test
not ok 2 - adds two numbers
  expected 5, got 6
Error: Process completed with exit code 1.

The last line only says that something failed. The useful part is above it. Search upward for the first error, because later messages are often consequences of the first one. Check the earlier steps too: a warning during installation can explain a later failure.

Making logs easier to read

You can group output and add annotations with special commands:

bash
echo "::group::Tool versions"
bash --version
echo "::endgroup::"
echo "::warning::Cache was empty"

The group folds in the web view, and the warning is highlighted. Printing tool versions early is a cheap way to explain differences between machines.

For more detail, you can rerun a failed job with debug logging enabled, or set the repository secret or variable ACTIONS_STEP_DEBUG to true.

Secrets in logs

GitHub replaces the values of registered secrets with ***. This masking is a safety net, not a guarantee. A transformed secret, for example base64 encoded, may not be recognised. Never print secrets, and be careful with commands that dump the whole environment or use set -x. If a secret does appear in a log, rotate it: deleting the log is not enough.

Try it

Add a step with run: exit 3 to a practice workflow. Run it, then find the failed step on the web page and with gh run view --log-failed. Note the exit code in the message. The search and archives lab is good practice for picking errors out of long output with grep.

The official Actions documentation describes the other log commands.

Check your understanding

Workflow Logs

All 3 sections · no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.