DriftGuard can post schema drift reports as PR comments. See .github/workflows/driftguard-pr.yml for a working example.
-
Install DriftGuard in your CI:
- run: pip install driftguard-contracts
-
Get baseline (from main branch or artifact):
- run: git show origin/main:openapi.yaml > /tmp/baseline.yaml
-
Run diff:
- run: driftguard openapi diff /tmp/baseline.yaml openapi.yaml --format markdown --output report.md
-
Post comment:
- uses: marocchino/sticky-pull-request-comment@v2 with: path: report.md
PR comment requires pull-requests: write permission:
permissions:
contents: read
pull-requests: writeWrite report to $GITHUB_STEP_SUMMARY for the Actions UI:
- run: cat report.md >> "$GITHUB_STEP_SUMMARY"| Strategy | When to use |
|---|---|
git show origin/main:spec.yaml |
Spec checked into repo |
| Download artifact from previous run | Snapshot stored as CI artifact |
| Download from S3/GCS | Snapshot stored externally |
- uses: actions/download-artifact@v4
with:
name: baseline-snapshot
path: /tmp/baseline/
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.pull_request.base.sha }}- uses: actions/upload-artifact@v4
with:
name: current-snapshot
path: drift-report.md
retention-days: 30| Parameter | Description | Default |
|---|---|---|
baseline |
Path to baseline spec | required |
current |
Path to current spec | required |
--format |
Output format: terminal, json, markdown, html | terminal |
--output |
Save to file | stdout |
--only-breaking |
Show only breaking changes | false |
| Format | Use Case |
|---|---|
markdown |
PR comments, step summary |
json |
Custom processing, dashboards |
html |
Standalone artifact |
terminal |
Local debugging |
DriftGuard JSON output can be converted to GitHub annotations using jq:
- name: Annotate breaking changes
run: |
driftguard openapi diff baseline.yaml current.yaml --format json | \
jq -r '.changes[] | select(.severity == "breaking") | "::error ::\(.description)"'For GitHub Code Scanning, convert DriftGuard output to SARIF:
- name: Generate SARIF
run: |
driftguard openapi diff baseline.yaml current.yaml --format json | \
python scripts/to_sarif.py > results.sarif
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif