Skip to content

Commit bca8a4b

Browse files
authored
implemented the pr-review action in this repo (#37)
1 parent bd5439a commit bca8a4b

4 files changed

Lines changed: 103 additions & 7 deletions

File tree

.github/pull_request_template.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Related Issues
2+
3+
<!-- e.g. Fixes #123 -->
4+
5+
## Summary
6+
7+
<!-- Brief description of changes -->
8+
9+
---
10+
11+
> [!TIP]
12+
> Comment `/review` to trigger the PR Reviewer agent for automated feedback.
13+
> Comment `/describe` to generate a PR description.

.github/workflows/review-pr.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
# Reusable workflow for AI-powered PR reviews
2+
#
23
# Usage:
34
# name: PR Review
45
# on:
5-
# issue_comment:
6+
# issue_comment: # Enables /review command in PR comments
67
# types: [created]
7-
# pull_request_review_comment:
8+
# pull_request_review_comment: # Captures feedback on review comments for learning
89
# types: [created]
9-
# pull_request_target:
10+
# pull_request_target: # Triggers auto-review on PR open; uses base branch context so secrets work with forks
1011
# types: [ready_for_review, opened]
1112
#
1213
# jobs:
1314
# review:
1415
# uses: docker/cagent-action/.github/workflows/review-pr.yml@latest
15-
# secrets: inherit
16+
# # Scoped to the job so other jobs in this workflow aren't over-permissioned
1617
# permissions:
17-
# contents: read
18-
# pull-requests: write
19-
# issues: write
18+
# contents: read # Read repository files and PR diffs
19+
# pull-requests: write # Post review comments and approve/request changes
20+
# issues: write # Create security incident issues if secrets are detected in output
21+
# secrets:
22+
# ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
23+
# CAGENT_ORG_MEMBERSHIP_TOKEN: ${{ secrets.CAGENT_ORG_MEMBERSHIP_TOKEN }} # PAT with read:org scope; gates auto-reviews to org members only
24+
# CAGENT_REVIEWER_APP_ID: ${{ secrets.CAGENT_REVIEWER_APP_ID }} # GitHub App ID; reviews appear as your app instead of github-actions[bot]
25+
# CAGENT_REVIEWER_APP_PRIVATE_KEY: ${{ secrets.CAGENT_REVIEWER_APP_PRIVATE_KEY }} # GitHub App private key; paired with App ID above
2026

2127
name: PR Review
2228

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Dogfoods the PR review workflow on this repo's own PRs.
2+
# This follows the same pattern recommended in review-pr/README.md,
3+
# using a local ref (./) instead of docker/cagent-action/...@latest.
4+
5+
name: Self PR Review
6+
7+
on:
8+
issue_comment:
9+
types: [created]
10+
pull_request_review_comment:
11+
types: [created]
12+
pull_request_target:
13+
types: [ready_for_review, opened]
14+
15+
permissions:
16+
contents: read
17+
pull-requests: write
18+
issues: write
19+
20+
jobs:
21+
review:
22+
uses: ./.github/workflows/review-pr.yml
23+
secrets: inherit

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,60 @@ jobs:
277277
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
278278
```
279279

280+
### PR Review Workflow (Reusable)
281+
282+
This repo provides a **reusable workflow** at `.github/workflows/review-pr.yml` that adds AI-powered PR reviews to any repository. It supports automatic reviews on PR open, manual `/review` comments, and feedback learning.
283+
284+
#### Setup (Explicit Secrets — No `secrets: inherit`)
285+
286+
This is the security-team-friendly approach. Only the secrets the workflow needs are passed explicitly — nothing else from your repository leaks across the boundary:
287+
288+
```yaml
289+
name: PR Review
290+
on:
291+
issue_comment: # Enables /review command in PR comments
292+
types: [created]
293+
pull_request_review_comment: # Captures feedback on review comments for learning
294+
types: [created]
295+
pull_request_target: # Triggers auto-review on PR open; uses base branch context so secrets work with forks
296+
types: [ready_for_review, opened]
297+
298+
jobs:
299+
review:
300+
uses: docker/cagent-action/.github/workflows/review-pr.yml@latest
301+
# Scoped to the job so other jobs in this workflow aren't over-permissioned
302+
permissions:
303+
contents: read # Read repository files and PR diffs
304+
pull-requests: write # Post review comments and approve/request changes
305+
issues: write # Create security incident issues if secrets are detected in output
306+
secrets:
307+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
308+
CAGENT_ORG_MEMBERSHIP_TOKEN: ${{ secrets.CAGENT_ORG_MEMBERSHIP_TOKEN }} # PAT with read:org scope; gates auto-reviews to org members only
309+
CAGENT_REVIEWER_APP_ID: ${{ secrets.CAGENT_REVIEWER_APP_ID }} # GitHub App ID; reviews appear as your app instead of github-actions[bot]
310+
CAGENT_REVIEWER_APP_PRIVATE_KEY: ${{ secrets.CAGENT_REVIEWER_APP_PRIVATE_KEY }} # GitHub App private key; paired with App ID above
311+
```
312+
313+
> **Why not `secrets: inherit`?** Using explicit secrets follows the principle of least privilege — the called workflow only receives the secrets it actually needs, not every secret in your repository. This is the recommended approach for public repos and security-conscious teams.
314+
315+
If you use a different LLM provider, replace `ANTHROPIC_API_KEY` with the appropriate secret (e.g., `OPENAI_API_KEY`, `GOOGLE_API_KEY`). See the full list in the secrets reference below.
316+
317+
#### Reusable Workflow Secrets Reference
318+
319+
| Secret | Required | Description |
320+
| ------ | -------- | ----------- |
321+
| `ANTHROPIC_API_KEY` | Yes* | Anthropic API key (or any one LLM key below) |
322+
| `OPENAI_API_KEY` | No* | OpenAI API key |
323+
| `GOOGLE_API_KEY` | No* | Google Gemini API key |
324+
| `AWS_BEARER_TOKEN_BEDROCK` | No* | AWS Bedrock bearer token |
325+
| `XAI_API_KEY` | No* | xAI Grok API key |
326+
| `NEBIUS_API_KEY` | No* | Nebius API key |
327+
| `MISTRAL_API_KEY` | No* | Mistral API key |
328+
| `CAGENT_ORG_MEMBERSHIP_TOKEN` | No | Classic PAT with `read:org` scope for auto-review gating |
329+
| `CAGENT_REVIEWER_APP_ID` | No | GitHub App ID for custom reviewer identity |
330+
| `CAGENT_REVIEWER_APP_PRIVATE_KEY` | No | GitHub App private key (paired with App ID) |
331+
332+
_*At least one LLM API key is required._
333+
280334
### Manual Trigger with Inputs
281335

282336
```yaml

0 commit comments

Comments
 (0)