Post Safegres Audit Results on GitHub Pull Requests
Dan Lynch
The CI check already writes a job summary. Optionally, let Safegres post that audit's grades and diff as a Markdown comment on trusted pull requests. Safegres updates the same comment on each PR run.
Enable the comment
In the audit job's existing permissions block, add:
yamlpull-requests: write
Under with on the Safegres step, add:
yamlcomment: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }}
This posts only for branches in your repository. Use it when you trust the people who can push branches there. Keep write tokens disabled for fork workflows, and don't switch to pull_request_target to run code or migrations from a fork. Fork PRs still get a check and job summary without the comment.
Read the diff
Run the workflow on main first to upload a report. On the next PR, Safegres compares against a recent successful base-branch report from the PR's history. Without a matching report, the card still shows grades, just no diff.
The example Safegres card shows what changed when a migration added a foreign key without an index:
The card lists the new X1 finding. Report-only mode shows it without blocking the PR; the comparison with main is separate from the performance baseline that controls the gate.

