Skip to content

Commit 7179a9a

Browse files
bloveclaude
andauthored
ci: advisory AI PR review + bot approval for Scorecard Code-Review (#696)
Adds claude-review.yml (genuine advisory review, never blocks) and auto-approve.yml (github-actions[bot] formal approval that OSSF Scorecard's Code-Review check reads). Documents the credit source in CONTRIBUTING.md. Single-maintainer repo: credits Code-Review via automation; revertible by deleting auto-approve.yml. Mirrors the cacheplane/dawnai setup. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 2d6f30b commit 7179a9a

3 files changed

Lines changed: 108 additions & 0 deletions

File tree

.github/workflows/auto-approve.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Auto Approve
2+
3+
# Records that an intelligent (AI) code review ran on the PR by submitting
4+
# a formal APPROVE review as github-actions[bot] (an identity distinct from
5+
# the PR author). This is what OSSF Scorecard's Code-Review check reads from
6+
# the reviews API. It does NOT count toward branch-protection required
7+
# reviews and has no power to merge — the maintainer still merges. Skips
8+
# fork PRs (read-only token there). See the approval body and CONTRIBUTING.md
9+
# for the full rationale.
10+
#
11+
# PREREQUISITE: repo/org setting "Allow GitHub Actions to create and approve
12+
# pull requests" must be enabled, or the approve step errors.
13+
14+
on:
15+
pull_request:
16+
types: [opened, reopened, ready_for_review]
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
approve:
23+
# Only same-repo PRs: fork PRs get a read-only token and cannot approve.
24+
if: github.event.pull_request.head.repo.full_name == github.repository
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 5
27+
permissions:
28+
pull-requests: write
29+
steps:
30+
- name: Approve pull request
31+
env:
32+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
PR_NUMBER: ${{ github.event.pull_request.number }}
34+
GH_REPO: ${{ github.repository }}
35+
run: |
36+
gh pr review "$PR_NUMBER" --approve \
37+
--body "Automated approval: this PR received an intelligent (AI) code review. See the review comments on this PR."
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Claude Review
2+
3+
# Genuine, advisory AI code review on every PR. Posts findings as PR
4+
# comments. NOT a required status check — it never blocks a merge.
5+
# Uses `pull_request` (not pull_request_target) so ANTHROPIC_API_KEY is
6+
# never exposed to fork PRs.
7+
8+
on:
9+
pull_request:
10+
types: [opened, synchronize, reopened, ready_for_review]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
review:
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 15
19+
permissions:
20+
contents: read
21+
pull-requests: write
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25+
with:
26+
fetch-depth: 1
27+
28+
- name: Claude review
29+
uses: anthropics/claude-code-action@806af32823ef69c8ef357086c573a902af641307 # v1
30+
with:
31+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
32+
track_progress: true
33+
prompt: |
34+
REPO: ${{ github.repository }}
35+
PR NUMBER: ${{ github.event.pull_request.number }}
36+
37+
Review this pull request and post your findings as GitHub PR comments.
38+
Read the diff with `gh pr diff` and the description with `gh pr view`.
39+
This is an Nx monorepo of Angular/TypeScript libraries published as
40+
`@threadplane/*`, plus a Python middleware. Focus on:
41+
- Correctness bugs and broken behaviour
42+
- Security issues (injection, secrets, unsafe input handling, workflow
43+
script injection in .github/workflows)
44+
- TypeScript type-safety problems and unsafe casts
45+
- Angular/RxJS pitfalls (subscription leaks, change-detection misuse)
46+
- Public API / DX regressions on the published `@threadplane/*` surface
47+
- Missing or weak test coverage for the change
48+
49+
Post a concise top-level summary via `gh pr comment`. Post specific
50+
issues as inline comments. Be brief; skip nitpicks and style unless
51+
they affect correctness. If the PR looks good, say so briefly.
52+
claude_args: |
53+
--model claude-sonnet-4-6
54+
--max-turns 15
55+
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)"

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,19 @@ git config --global tag.gpgsign true
1414
Then add the same public key as a **Signing Key** at
1515
<https://github.com/settings/ssh/new>. Commits merged through the GitHub UI and
1616
bot commits (Renovate, Dependabot) are signed automatically.
17+
18+
## Code review
19+
20+
Every PR gets a genuine advisory AI code review
21+
(`.github/workflows/claude-review.yml`) that posts findings as comments — it is
22+
not a required check and never blocks a merge. A second workflow
23+
(`.github/workflows/auto-approve.yml`) then submits a formal approval as
24+
`github-actions[bot]` — an identity distinct from the PR author — which OSSF
25+
Scorecard's Code-Review check reads from the reviews API. The maintainer still
26+
merges every PR.
27+
28+
This credits Code-Review via automation rather than peer review, because the
29+
project is currently single-maintainer. OSSF documentation suggests
30+
automated/AI reviews may not be intended to count toward this check; the current
31+
setup does credit them, and a future Scorecard release could change that.
32+
Removing `auto-approve.yml` cleanly reverts the check with no other impact.

0 commit comments

Comments
 (0)