GitHub Action
The redpennon/cli Action runs rp usages in CI, resolves the Git context, and posts a snapshot to the code references API. It is the side-effecting half of the workflow — rp usages itself never posts.
Workflow
Add .github/workflows/redpennon-usages.yml:
name: RedPennon Code References
on:
push:
branches: [main]
jobs:
usages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: redpennon/cli@v1
with:
api-token: ${{ secrets.REDPENNON_API_TOKEN }}
project: your-project-key
fetch-depth: 0 gives the Action full Git context to resolve the repository, branch, and commit.
Inputs
| Input | Required | Description |
|---|---|---|
api-token | yes | Organisation API token (rpa_…). Store it as a repository secret. |
project | yes | Project key the references belong to. |
api-url | no | Override the API base URL (self-hosted / development). Must be https://, or http:// for localhost only. |
working-directory | no | Directory to scan, relative to the workspace. Defaults to the workspace root. Must exist and stay inside the workspace. |
config-path | no | Path to the config file, relative to the working directory. Defaults to .redpennon/config.yml. Must exist when set. |
fail-on-unknown | no | true fails the step when the API reports keys that are not in the project. Defaults to false, which only warns. |
max-references | no | Fail instead of publishing more than this many references. Defaults to 2000, the API's per-snapshot limit. |
For a monorepo package:
- uses: redpennon/cli@v1
with:
api-token: ${{ secrets.REDPENNON_API_TOKEN }}
project: your-project-key
working-directory: packages/web
config-path: .redpennon/web.yml
fail-on-unknown: true
Outputs: accepted, matched and unknown-keys (comma-separated).
What it sends
The Action resolves the Git context from the environment — repository from GITHUB_REPOSITORY, branch from GITHUB_HEAD_REF on pull request events (the PR's source branch) and GITHUB_REF_NAME otherwise, commit_sha from GITHUB_SHA — and POSTs the scan with provider: github to POST /v1/code-references. Because each push is a full snapshot, references that disappear are marked stale automatically.
Snippets are capped at 200 characters and common secret shapes (rpa_ tokens, AWS access keys, Bearer …, and password/secret/token assignments) are replaced with [REDACTED] before anything is sent.
Secrets
Create the organisation API token under Settings → API tokens in the app, then add it to the repository under Settings → Secrets and variables → Actions as REDPENNON_API_TOKEN.
The Action is published on the GitHub Marketplace and bundled (no npm install step needed in your workflow).