GitHub
Use brin in GitHub Actions to check contributor trust and scan commits on every pull request
Integrate brin into your GitHub CI pipeline with Actions workflows that automatically check contributor trust and scan commits for security signals on every pull request.
##Contributor checks
Add a workflow that queries the brin contributor API for every PR author. It labels PRs as contributor:verified or contributor:flagged and posts a detailed comment when review is recommended.
###What it does
When a pull request is opened, reopened, or updated, the workflow:
- Queries the brin contributor API for the PR author's trust score
- Applies a label —
contributor:verified(safe) orcontributor:flagged(needs review) - Posts a comment with threat signals, dimension breakdown, and a link to the full profile when flagged
- Cleans up the comment automatically when a previously-flagged contributor is re-evaluated as safe
###Workflow
Create .github/workflows/contributor-check.yml in your repository:
###How it works
The workflow uses pull_request_target so it has write access to add labels and comments, even on PRs from forks. It runs in two steps:
- Query the brin API — calls the contributor endpoint with
details=true&mode=fullto get the full trust profile for the PR author. If the API is unreachable, it falls back to an empty JSON object and exits gracefully. - Label and comment — ensures
contributor:verifiedandcontributor:flaggedlabels exist, applies the appropriate one, and posts a detailed comment on flagged PRs with threat signals and a dimension breakdown. The comment uses an HTML marker to find and update itself on subsequent runs.
The concurrency setting ensures only one check runs per PR at a time. If a new commit is pushed while a check is in progress, the running check is cancelled and replaced.
###Blocking merges on flagged contributors
Add a branch protection rule that requires the "Scan PR author" status check to pass. The workflow always succeeds (it labels rather than fails), so to enforce a merge block you can add a step that exits with a non-zero code when the verdict is not safe:
##Commit scanning
Add a workflow that scans every commit in a pull request through the brin commit API. This catches malicious or suspicious code changes regardless of who authored them.
###What it does
When a pull request is opened or updated, the workflow:
- Checks out the PR commits and collects their SHAs
- Queries the brin commit API for each commit
- Fails the check if any commit is flagged as
suspiciousordangerous - Posts a summary comment listing flagged commits with their scores and threat details
###Workflow
Create .github/workflows/commit-scan.yml in your repository:
###How it works
The workflow checks out the full PR history, then iterates over each commit between the base and head SHAs. For each commit, it calls the brin commit API (/commit/owner/repo@sha) with details=true to get the full security analysis.
If any commit returns a suspicious or dangerous verdict, the workflow:
- Posts a comment with a table of flagged commits, their scores, verdicts, and threat details
- Fails the check so branch protection rules can block the merge
When all commits are clean on a subsequent run, the workflow removes any previous scan comment.
###Combining with contributor checks
You can run both workflows in the same repository. They operate independently — contributor checks evaluate the PR author's profile, while commit scanning evaluates the actual code changes. Together they provide defense in depth: even a trusted contributor's compromised account would be caught if the commits contain malicious patterns.
On this page