Sub topic 14
Debugging and log output
This chapter assumes you can write a composite action with inputs, outputs and shell on every run step, and that you know basic bash. Composite actions give you few debugging tools of their own, so you rely on the runner's logging features.
Where composite logs appear
Each step inside a composite action shows up as a nested line under the calling step in the job log. A failure points to the inner step that failed. If a step has no name, the log shows the command text, which is hard to read. Name your steps.
runs:
using: composite
steps:
- name: Build greeting
id: build
shell: bash
env:
WHO: ${{ inputs.who-to-greet }}
run: echo "greeting=Hello, ${WHO}" >> "$GITHUB_OUTPUT"Workflow commands for log output
A workflow command is a line printed to standard output in a special format. The runner reads it and changes how the log looks.
| Command | Effect |
|---|---|
| `::debug::message` | Shown only when debug logging is on |
| `::notice::message` | Shows an annotation on the run summary |
| `::warning::message` | Shows a warning annotation |
| `::error::message` | Shows an error annotation (does not fail the step) |
| `::group::title` and `::endgroup::` | Collapses lines between them |
The ::error:: command only labels a problem. To fail the step, also exit with a non-zero code.
- name: Validate input
shell: bash
env:
VERSION: ${{ inputs.node-version }}
run: |
echo "::group::Validating inputs"
if [[ ! "$VERSION" =~ ^[0-9]+$ ]]; then
echo "::error title=Bad input::node-version must be a number, got '$VERSION'"
exit 1
fi
echo "::debug::node-version is $VERSION"
echo "::endgroup::"Turning on debug logging
Set the repository secret or variable ACTIONS_STEP_DEBUG to true. Then ::debug:: lines appear in the log. You can also re-run a job with "Enable debug logging" selected, which needs no settings change. Set ACTIONS_RUNNER_DEBUG to true for extra runner diagnostics.
Tracing shell steps
For bash, set -x prints each command before it runs. Use it in the step you are investigating, not everywhere.
- name: Run bundled check
shell: bash
run: |
set -euxo pipefail
bash "${{ github.action_path }}/scripts/check.sh"The flags -e (stop on error), -u (error on unset variables) and -o pipefail (fail if any command in a pipe fails) catch many silent mistakes.
Common problems
- An output is empty. Check that the action's
outputs.<name>.valuepoints tosteps.<id>.outputs.<name>, and that the step has anid. A missingidis the most common cause. - An input is empty. Inputs are strings. A missing
with:key gives the default, or an empty string if there is no default. - "Required property is missing: shell". Add
shellto everyrunstep. - A script is not found. Use
${{ github.action_path }}rather than a relative path. Relative paths resolve against the caller's workspace. - A script is not executable. Run it with
bash script.sh, or commit it withchmod +x.
Inspecting context
To see what the runner provides, print a few values in a temporary step.
- name: Show context
shell: bash
run: |
echo "action path: ${{ github.action_path }}"
echo "workspace: $GITHUB_WORKSPACE"
ls -la "${{ github.action_path }}"Remove this step before you release the action.
Exercise
A composite step prints ::error::Config missing but the job still shows as successful. Why, and how do you fix it?
Show answer
The ::error:: workflow command only creates an error annotation. It does not change the step's exit code. Add exit 1 after the echo so the step fails.
Exercise
How can you see ::debug:: messages from a composite action without editing any repository settings?
Show answer
Re-run the job from the Actions page and select "Enable debug logging". This turns on step debug output for that run only.