Skip to content

Commit 61e1c58

Browse files
committed
Initial release: OpenRouter PR Review Action
0 parents  commit 61e1c58

8 files changed

Lines changed: 42420 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Test PR Review Action
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
jobs:
8+
test-pr-review:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- name: Test OpenRouter PR Review
14+
uses: ./
15+
with:
16+
github_token: ${{ secrets.GITHUB_TOKEN }}
17+
open_router_key: ${{ secrets.OPEN_ROUTER_KEY }}
18+
model_id: 'anthropic/claude-2'

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Logs
5+
npm-debug.log*
6+
yarn-debug.log*
7+
yarn-error.log*
8+
9+
# IDE
10+
.idea/
11+
.vscode/
12+
*.swp
13+
*.swo
14+
15+
# OS
16+
.DS_Store
17+
Thumbs.db

README.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# OpenRouter PR Review Action
2+
3+
This GitHub Action integrates with OpenRouter to review pull request diffs, suggest improvements, and scan for vulnerabilities using AI models of your choice.
4+
5+
## Features
6+
7+
- Automated PR code review using AI
8+
- Customizable AI models through OpenRouter
9+
- Vulnerability and bug detection
10+
- Code improvement suggestions
11+
- Custom prompts for specialized analysis
12+
- Performance and security insights
13+
14+
## Inputs
15+
16+
| Input | Description | Required | Default |
17+
| ----------------- | ------------------------------------------ | -------- | -------------------------- |
18+
| `github_token` | GitHub token for API access | Yes | `${{ github.token }}` |
19+
| `open_router_key` | Your OpenRouter API key | Yes | - |
20+
| `model_id` | Model ID to use (e.g., anthropic/claude-2) | Yes | anthropic/claude-2 |
21+
| `custom_prompt` | Custom prompt for specialized analysis | No | Default code review prompt |
22+
| `max_tokens` | Maximum tokens in response | No | 2048 |
23+
24+
## Usage
25+
26+
1. Create a new workflow file (e.g., `.github/workflows/pr-review.yml`):
27+
28+
```yaml
29+
name: PR Review
30+
31+
on:
32+
pull_request:
33+
types: [opened, synchronize]
34+
35+
jobs:
36+
review:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v2
41+
42+
- name: OpenRouter PR Review
43+
uses: your-username/openrouter-pr-review@v1
44+
with:
45+
github_token: ${{ secrets.GITHUB_TOKEN }}
46+
open_router_key: ${{ secrets.OPEN_ROUTER_KEY }}
47+
model_id: 'anthropic/claude-2'
48+
```
49+
50+
### Custom Prompt Example
51+
52+
You can customize the analysis by providing your own prompt:
53+
54+
```yaml
55+
- name: OpenRouter PR Review
56+
uses: your-username/openrouter-pr-review@v1
57+
with:
58+
github_token: ${{ secrets.GITHUB_TOKEN }}
59+
open_router_key: ${{ secrets.OPEN_ROUTER_KEY }}
60+
model_id: 'openai/gpt-4'
61+
custom_prompt: |
62+
You are a security-focused code reviewer. Please analyze this code diff with emphasis on:
63+
1. Security vulnerabilities
64+
2. Authentication/authorization issues
65+
3. Data validation
66+
4. Input sanitization
67+
5. Secure coding practices
68+
```
69+
70+
## Publishing and Testing Guide
71+
72+
### Local Testing
73+
74+
1. Clone this repository
75+
2. Create a new branch for testing:
76+
```bash
77+
git checkout -b test-action
78+
```
79+
3. Make some changes to test
80+
4. Create a pull request
81+
5. Add your OpenRouter API key to repository secrets as `OPEN_ROUTER_KEY`
82+
6. The action will automatically run on your PR
83+
84+
### Publishing to GitHub Marketplace
85+
86+
1. Push your code to GitHub:
87+
88+
```bash
89+
git add .
90+
git commit -m "Initial release"
91+
git push origin main
92+
```
93+
94+
2. Create a new release:
95+
96+
- Go to your repository on GitHub
97+
- Click "Releases"
98+
- Click "Create a new release"
99+
- Choose a tag (e.g., "v1.0.0")
100+
- Title the release (e.g., "Initial Release")
101+
- Publish the release
102+
103+
3. Update in Other Repositories:
104+
```yaml
105+
- uses: your-username/openrouter-pr-review@v1
106+
```
107+
Replace `your-username` with your GitHub username
108+
109+
### Testing in Other Repositories
110+
111+
1. Add the action to your repository's workflow:
112+
113+
```yaml
114+
name: PR Review
115+
on:
116+
pull_request:
117+
types: [opened, synchronize]
118+
119+
jobs:
120+
review:
121+
runs-on: ubuntu-latest
122+
steps:
123+
- uses: actions/checkout@v3
124+
- uses: your-username/openrouter-pr-review@v1
125+
with:
126+
github_token: ${{ secrets.GITHUB_TOKEN }}
127+
open_router_key: ${{ secrets.OPEN_ROUTER_KEY }}
128+
model_id: 'anthropic/claude-2'
129+
```
130+
131+
2. Add your OpenRouter API key:
132+
133+
- Go to repository Settings
134+
- Select Secrets and variables → Actions
135+
- Create a new secret named `OPEN_ROUTER_KEY`
136+
- Add your OpenRouter API key as the value
137+
138+
3. Create a test PR to verify the action works
139+
140+
## Models
141+
142+
Some recommended models:
143+
144+
- `anthropic/claude-2`: Excellent for detailed code analysis
145+
- `openai/gpt-4`: Strong general-purpose code review
146+
- `anthropic/claude-instant-v1`: Faster, more economical option
147+
148+
## License
149+
150+
This project is licensed under the MIT License.

action.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 'OpenRouter PR Review Action'
2+
description: 'A GitHub Action to review PR diffs, suggest improvements, and scan for vulnerabilities using OpenRouter.'
3+
inputs:
4+
github_token:
5+
description: 'GitHub token for API access'
6+
required: true
7+
default: '${{ github.token }}'
8+
open_router_key:
9+
description: 'Your OpenRouter API key'
10+
required: true
11+
model_id:
12+
description: 'The model ID to use for analysis (e.g., anthropic/claude-2, openai/gpt-4)'
13+
required: true
14+
default: 'anthropic/claude-2'
15+
custom_prompt:
16+
description: 'Custom prompt for the AI analysis. If not provided, a default prompt focusing on code review aspects will be used.'
17+
required: false
18+
max_tokens:
19+
description: 'Maximum number of tokens in the response'
20+
required: false
21+
default: '2048'
22+
runs:
23+
using: 'node16'
24+
main: 'dist/index.js'
25+
branding:
26+
icon: 'eye'
27+
color: 'blue'

0 commit comments

Comments
 (0)