Skip to content

Commit f7405d0

Browse files
committed
ci(repo): post snapi report as sticky PR comment
When `api-changes-report.md` exists, the check-api job now finds or creates a marker-tagged comment on the PR and replaces its body with the report. The no-changes case posts a single short line instead of the full report to keep noise down on PRs that touch a watched package without changing the API surface. peter-evans/find-comment and peter-evans/create-or-update-comment are pinned by commit SHA.
1 parent adc1ce6 commit f7405d0

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/api-changes.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ jobs:
8787
name: API Changes
8888
runs-on: 'blacksmith-8vcpu-ubuntu-2204'
8989
continue-on-error: true
90+
permissions:
91+
contents: read
92+
pull-requests: write
9093
defaults:
9194
run:
9295
shell: bash
@@ -164,3 +167,39 @@ jobs:
164167
path: api-changes-report.md
165168
if-no-files-found: ignore
166169
retention-days: 5
170+
171+
- name: Build snapi comment body
172+
if: always()
173+
id: report
174+
run: |
175+
if [ ! -f api-changes-report.md ]; then
176+
exit 0
177+
fi
178+
{
179+
echo 'body<<SNAPI_REPORT_EOF'
180+
echo '<!-- snapi-report -->'
181+
if grep -q '## No API Changes Detected' api-changes-report.md; then
182+
echo '**Snapi**: no API changes detected in `@clerk/clerk-js`, `@clerk/react`, `@clerk/shared`, `@clerk/ui`.'
183+
else
184+
cat api-changes-report.md
185+
fi
186+
echo 'SNAPI_REPORT_EOF'
187+
} >> "$GITHUB_OUTPUT"
188+
189+
- name: Find existing snapi comment
190+
if: always() && steps.report.outputs.body != ''
191+
id: find-comment
192+
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
193+
with:
194+
issue-number: ${{ github.event.pull_request.number }}
195+
comment-author: 'github-actions[bot]'
196+
body-includes: '<!-- snapi-report -->'
197+
198+
- name: Post snapi report
199+
if: always() && steps.report.outputs.body != ''
200+
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0
201+
with:
202+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
203+
issue-number: ${{ github.event.pull_request.number }}
204+
body: ${{ steps.report.outputs.body }}
205+
edit-mode: replace

0 commit comments

Comments
 (0)