Automate
Run the CLI in CI
Fail a pipeline on the observations you care about, using a service token instead of a person's sign-in.
On this page
Create a service token
Create the token
In grcHero, open Settings, API tokens. Create a service token with the contributor role and the Command line scans permission.
Store it as a secret
Save it in your CI provider's secret store as
GRCHERO_API_TOKEN, masked from logs. Save your workspace ID asGRCHERO_ORGANIZATION_ID.
Note: A service token is its own identity, named on the CLI page and in the activity log, and keeps working when people leave. It needs no browser sign-in.
Add a job
name: grcHero review
on: pull_request
permissions:
contents: read
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: curl -fsSL https://grchero.dev/install.sh | sh
- run: ~/.local/bin/grchero scan . --fail-on medium
env:
GRCHERO_API_TOKEN: ${{ secrets.GRCHERO_API_TOKEN }}
GRCHERO_ORGANIZATION_ID: ${{ vars.GRCHERO_ORGANIZATION_ID }}Show observations in pull requests
--format sarif writes SARIF 2.1.0, which GitHub code scanning and other tools show inline on the changed lines. Each observation carries a stable fingerprint, so an alert stays the same alert across runs.
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- run: curl -fsSL https://grchero.dev/install.sh | sh
- run: ~/.local/bin/grchero scan . --format sarif > grchero.sarif
env:
GRCHERO_API_TOKEN: ${{ secrets.GRCHERO_API_TOKEN }}
GRCHERO_ORGANIZATION_ID: ${{ vars.GRCHERO_ORGANIZATION_ID }}
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: grchero.sarifFail only on new observations
Adopting checks on an existing project should not block every pull request. Save a report once, commit it as your baseline, and only observations that are not in it count for --fail-on. The output marks known ones as "in baseline".
An observation is matched by its rule, file and wording, not its line, so moving code around does not make an old observation new.
grchero scan . --output .grchero-baseline.json
grchero scan . --baseline .grchero-baseline.json --fail-on mediumChoose when to fail
Observations do not fail the command unless you set --fail-on. high fails on high observations, medium on medium and high, low on all. A preview never fails on observations.
Exit codes
| Code | Meaning |
|---|---|
0 | Review finished below the threshold, or another command succeeded |
1 | Review finished with observations at or above --fail-on, or grcHero refused the request or could not be reached |
2 | Invalid options, configuration, scope, report or sign-in, or a file error |
3 | Waiting for a person to confirm in the browser |
4 | Not allowed for this token, role or agent setting |
130 | Cancelled with Ctrl+C |