How to Emit Annotations from CI in GitHub Actions
The ::error and ::warning workflow commands attach messages to a file and line, surfacing them inline on the PR.
Print ::error file=...,line=...::message (or ::warning) from a step. GitHub renders these as annotations in the run summary and inline on changed files in the pull request.
Steps
- Emit
::error file=<path>,line=<n>::<message>from a step. - Use
::warningfor non-blocking notes. - Group repeated output with
::group::and::endgroup::.
Workflow
.github/workflows/ci.yml
- name: Lint
run: |
if ! npm run lint; then
echo "::error file=src/app.js,line=42::Unused variable"
exit 1
fiGotchas
- An
::errormessage alone does not fail the job; you still need a non-zero exit. - Annotations count toward a per-run cap, so keep them targeted.
Related guides
How to Choose Between Check Runs and Commit StatusesUnderstand the difference between GitHub check runs and commit statuses, and create a rich check run with the…
How to Create a Commit Status from CI with the Status APICreate a commit status from CI using the GitHub statuses API, posting a state, context, and target URL agains…
How to Add a GitHub Actions Workflow Status BadgeAdd a GitHub Actions workflow status badge to your README by linking the built-in badge.svg endpoint for a sp…