1- # OpenRouter PR Review Action
1+ # OpenRouter GitHub Action
22
3- This GitHub Action integrates with OpenRouter to review pull request diffs, suggest improvements , and scan for vulnerabilities using AI models of your choice .
3+ AI-powered PR reviews using OpenRouter's language models. Get automated code reviews, suggestions , and vulnerability scanning on your pull requests .
44
5- ## Features
5+ ## ⚠️ Security First: Managing Secrets
66
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
7+ This action requires an OpenRouter API key. ** NEVER** commit API keys or sensitive data directly in your workflow files.
138
14- ## Inputs
9+ ### Setting up Secrets
1510
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 |
11+ 1 . Get your OpenRouter API key from [ OpenRouter ] ( https://openrouter.ai/keys )
12+ 2 . Add it to GitHub Secrets:
13+ - Go to your repository's Settings
14+ - Navigate to Secrets and variables → Actions
15+ - Click "New repository secret"
16+ - Create a secret named ` OPEN_ROUTER_KEY `
17+ - Paste your OpenRouter API key as the value
2318
24- ## Usage
19+ The ` GITHUB_TOKEN ` is automatically provided by GitHub Actions - you don't need to set it up manually.
2520
26- 1 . Create a new workflow file (e.g., ` .github/workflows/pr-review.yml ` ):
21+ ## Quick Start
22+
23+ Create ` .github/workflows/pr-review.yml ` in your project:
2724
2825``` yaml
2926name : PR Review
30-
3127on :
3228 pull_request :
3329 types : [opened, synchronize]
@@ -36,115 +32,93 @@ jobs:
3632 review :
3733 runs-on : ubuntu-latest
3834 steps :
39- - name : Checkout code
40- uses : actions/checkout@v2
35+ - uses : actions/checkout@v3
4136
42- - name : OpenRouter PR Review
43- uses : your-username /openrouter-pr-review@v1
37+ - name : AI PR Review
38+ uses : jonit-dev /openrouter-github-action@main
4439 with :
45- github_token : ${{ secrets.GITHUB_TOKEN }}
46- open_router_key : ${{ secrets.OPEN_ROUTER_KEY }}
40+ github_token : ${{ secrets.GITHUB_TOKEN }} # Automatically provided
41+ open_router_key : ${{ secrets.OPEN_ROUTER_KEY }} # Must be set in repository secrets
4742 model_id : ' anthropic/claude-2'
4843` ` `
4944
50- ### Custom Prompt Example
45+ ## Features
46+
47+ - Automated PR code review using AI
48+ - Customizable AI models through OpenRouter
49+ - Vulnerability and bug detection
50+ - Code improvement suggestions
51+ - Custom prompts for specialized analysis
52+ - Performance and security insights
5153
52- You can customize the analysis by providing your own prompt:
54+ ## Configuration Options
55+
56+ | Input | Description | Required | Default | Security Note |
57+ | ----------------- | --------------------------- | -------- | --------------------- | ---------------------------------------- |
58+ | ` github_token` | GitHub token for API access | Yes | `${{ github.token }}` | Automatically provided by GitHub Actions |
59+ | `open_router_key` | Your OpenRouter API key | Yes | - | Must be stored in GitHub Secrets |
60+ | `model_id` | Model ID to use | Yes | anthropic/claude-2 | Safe to include in workflow file |
61+ | `custom_prompt` | Custom prompt for analysis | No | Default prompt | Safe to include in workflow file |
62+ | `max_tokens` | Maximum tokens in response | No | 2048 | Safe to include in workflow file |
63+
64+ # # Advanced Usage
65+
66+ # ## Custom Model
67+
68+ ` ` ` yaml
69+ - uses: jonit-dev/openrouter-github-action@main
70+ with:
71+ github_token: ${{ secrets.GITHUB_TOKEN }}
72+ open_router_key: ${{ secrets.OPEN_ROUTER_KEY }}
73+ model_id: 'openai/gpt-4' # Safe to customize
74+ ` ` `
75+
76+ # ## Custom Prompt
5377
5478` ` ` yaml
55- - name : OpenRouter PR Review
56- uses : your-username/openrouter-pr-review@v1
79+ - uses: jonit-dev/openrouter-github-action@main
5780 with:
5881 github_token: ${{ secrets.GITHUB_TOKEN }}
5982 open_router_key: ${{ secrets.OPEN_ROUTER_KEY }}
60- model_id : ' openai/gpt-4 '
83+ model_id: 'anthropic/claude-2 '
6184 custom_prompt: |
62- You are a security-focused code reviewer. Please analyze this code diff with emphasis on:
85+ You are a security-focused reviewer. Analyze this PR with emphasis on:
6386 1. Security vulnerabilities
64- 2. Authentication/authorization issues
87+ 2. Authentication issues
6588 3. Data validation
6689 4. Input sanitization
67- 5. Secure coding practices
90+ 5. Best practices
6891` ` `
6992
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
93+ # # Available Models
14194
14295Some recommended models :
14396
14497- `anthropic/claude-2` : Excellent for detailed code analysis
14598- `openai/gpt-4` : Strong general-purpose code review
14699- `anthropic/claude-instant-v1` : Faster, more economical option
147100
101+ # # Testing Locally
102+
103+ 1. Clone this repository
104+ 2. Install dependencies : ` npm install`
105+ 3. Create a test branch : ` git checkout -b test-feature`
106+ 4. Make some changes
107+ 5. Create a PR
108+ 6. **Important** : Add your OpenRouter API key to repository secrets as `OPEN_ROUTER_KEY`
109+ - Never commit the API key directly
110+ - Never include it in environment files
111+ - Always use GitHub Secrets
112+ 7. The action will run automatically on your PR
113+
114+ # # Security Best Practices
115+
116+ 1. Always use GitHub Secrets for sensitive data
117+ 2. Never commit API keys or tokens
118+ 3. Don't log sensitive information in PR comments
119+ 4. Regularly rotate your OpenRouter API key
120+ 5. Use the minimum required permissions for the GitHub token
121+
148122# # License
149123
150124This project is licensed under the MIT License.
0 commit comments