Skip to content
Latchkey

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 ::warning for 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
          fi

Gotchas

  • An ::error message 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

Run this faster and cheaper on Latchkey managed runners. Start free →