Comment Drift Results on Pull Requests
Generate a Markdown drift report with vg scan --format markdown and post it as a pull request comment so reviewers see the DriftScore and findings inside the review.
Surfacing the DriftScore where reviewers already work, the pull request, makes drift part of the review conversation. The Vibgrate CLI can produce a Markdown report, which a workflow then posts as a PR comment.
Prerequisites
- Vibgrate running in GitHub Actions on pull requests.
- The workflow can request
pull-requests: writepermission.
Steps
1. Run the scan
Scan the PR branch so the report reflects the proposed changes.
vg scan
2. Generate a Markdown report
Use the Markdown output format and write it to a file you can read back into the comment body.
vg scan --format markdown --out drift-report.md
The report contains the DriftScore and a readable summary of the findings behind it.
3. Grant pull-requests permission
The comment step needs write access to pull requests.
permissions:
pull-requests: write
contents: read
4. Post the comment
Read the generated file and post it with your preferred comment action or the GitHub CLI, using the file as the comment body.
- run: npx @vibgrate/cli scan --format markdown --out drift-report.md
- run: gh pr comment "$PR_NUMBER" --body-file drift-report.md
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
5. Verify on a PR
Open a pull request and wait for the workflow. A comment with the DriftScore and findings should appear on the PR.
Verification
Confirm the comment shows up on the pull request and contains the DriftScore from the report file. If no comment appears, check that the job ran on a pull_request event and had pull-requests: write.
vg scan --format markdown --out drift-report.md
Next Steps
- Limit the report to changed files with
vg scan --changed-only. - Add a
--drift-budgetso the same run can also block the merge. - Push results to Vibgrate Cloud with
vg scan --pushfor historical context.