GitHub Actions: Debugging, Logs, and Troubleshooting

Debug failing GitHub Actions workflows with log grouping, debug logging, step summaries, shell flags, and common troubleshooting patterns.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Debug logging and log structure

Make logs easier to inspect and turn on deeper diagnostics when needed.

Create a collapsible log group

Group related output in the Actions log.

bashANYlogsgroup
bash
echo "::group::Install dependencies"
npm ci
echo "::endgroup::"
Notes

Log grouping keeps noisy steps readable.

Emit a notice annotation

Add an informational annotation to the run log.

bashANYnoticeannotations
bash
echo "::notice title=Build::Build completed successfully"
Notes

Workflow commands can create notices, warnings, and errors visible in the run UI.

Emit a warning annotation

Highlight a non-fatal issue in the run log.

bashANYwarningannotations
bash
echo "::warning file=package.json,line=1::Deprecated config detected"
Notes

Annotations make important issues much easier to spot in long logs.

Emit an error annotation

Mark a step error with file context.

bashANYerrorannotations
bash
echo "::error file=src/app.js,line=42::Build failed"
Notes

Useful when custom scripts want to surface failures in a GitHub-native way.

Write a markdown step summary

Add a rich markdown summary to the workflow run.

bashANYGITHUB_STEP_SUMMARYsummary
bash
echo "## Test Summary" >> "$GITHUB_STEP_SUMMARY"
Notes

Step summaries are excellent for concise results, links, and deployment info.

Shell failures and common fixes

Avoid brittle shell scripts and diagnose common workflow failures.

Use strict Bash mode

Fail fast in shell scripts.

bashANYbashstrict-mode
bash
set -euo pipefail
Notes

This catches missing variables and pipeline failures early.

Verify workspace contents

Check that expected files exist after checkout or artifact download.

bashANYworkspacefilesdebug
bash
find . -maxdepth 3 -type f | sort | head -200
Notes

A quick workspace listing often reveals wrong paths or missing artifacts.

Pin actions to a major or full version

Avoid unexpected behavior from drifting dependencies.

yamlANYpinningactions
yaml
- uses: actions/checkout@v4
Notes

Pinned versions improve predictability and security compared with unpinned references.

Retry a flaky network step in Bash

Wrap transient operations in a simple retry loop.

bashANYretryflaky
bash
for i in 1 2 3; do
  npm install && break
  sleep 5
done
Notes

Use sparingly for transient network issues while you investigate the real cause.

Recommended next

No recommendations yet.