How to Emit Annotations From a Custom Action
A custom action surfaces problems by printing ::error:: workflow commands or calling core.error.
Print ::error::message (or ::warning::, ::notice::) from a shell step, or call core.error from JavaScript. Annotations appear in the run summary and can point at a file and line.
Steps
- Print
::error file=...,line=...::messagefrom a shell step. - Or call
core.error,core.warning,core.noticein JavaScript. - Pair
::error::withexit 1to also fail the step.
Composite annotation
action.yml
run: |
echo "::error file=src/app.js,line=42::Type check failed"
echo "::warning::Deprecated flag in use"
exit 1
shell: bashJavaScript annotation
index.js
const core = require('@actions/core');
core.error('Type check failed', { file: 'src/app.js', startLine: 42 });
core.setFailed('Build failed');Gotchas
::error::alone does not fail the step; addexit 1orcore.setFailed.- Annotation counts per run are capped, so group related messages.
Related guides
How to Set Outputs From a Custom Action With GITHUB_OUTPUTSet an output from a composite or container action by appending name=value to the GITHUB_OUTPUT file, then ex…
How to Use @actions/exec and the Toolkit in a JavaScript ActionRun shell commands from a JavaScript action with @actions/exec and capture output, using @actions/core for in…
How to Validate Inputs in a Custom ActionValidate custom action inputs at runtime by checking allowed values and formats, then failing with ::error::…