A GitHub Action that provides automated code review using AI to analyze pull request changes.
- Automatically reviews pull request changes using AI
- Provides detailed code suggestions and improvements
- Adds review comments directly to the PR
- Works with any programming language
- Supports different AI models and API endpoints
- Optional review resolution statuses (e.g., "APPROVE", "REQUEST_CHANGES", "COMMENT")
- Debug mode for enhanced logging
This action uses LiteLLM, so it supports 100+ LLMs including:
- OpenAI (GPT-4o, o1, etc.)
- Anthropic (Claude 3.5 Sonnet, Claude 3.7 Sonnet, etc.)
- Google VertexAI / Gemini (Gemini 1.5 Pro, Gemini 2.0 Flash, etc.)
- Azure OpenAI
- HuggingFace
- Ollama
- ... and many more.
See the LiteLLM Providers documentation for the full list of supported models and the required environment variables for each provider.
I’ll grade them on a scale from 0 to 10, where:
- 0 → Completely irrelevant comments
- 3 → My fresh junior/mid-level colleague
- 5 → My mid-level colleague who reads Stack Overflow
- 8 → Me
- 10 → My very smart colleague
So, based on this (highly unscientific) scale:
- gpt-4o → 2
- o1 → 3
- claude-3-5-sonnet → 5
- claude-3-7-sonnet → 6
- gemini-2.0-flash → 2
- gemini-2.5-pro → 3
| Name | Description | Required | Default |
|---|---|---|---|
github_token |
GitHub token for authentication | true | - |
debug |
Enable debug mode (true/false) | false | false |
add_review_resolution |
Add review resolution (APPROVE, REQUEST_CHANGES, COMMENT) | false | false |
add_joke |
Add a joke to the review comment | false | false |
author_customization |
YAML configuration for customizing reviews based on PR author | false | - |
The action relies on environment variables for LLM configuration, handled by litellm.
| Name | Description | Required |
|---|---|---|
LLM_MODEL |
The model name to use (e.g. gpt-4o, claude-3-5-sonnet, gemini/gemini-1.5-pro) |
Yes |
OPENAI_API_KEY |
API Key for OpenAI (if using OpenAI models) | Conditional |
ANTHROPIC_API_KEY |
API Key for Anthropic (if using Claude models) | Conditional |
GEMINI_API_KEY |
API Key for Google Gemini (if using Gemini models) | Conditional |
OPENAI_API_BASE |
Custom API endpoint (if needed) | Optional |
Note: Check the LiteLLM documentation for the specific environment variables required for your chosen provider.
To use this action in your GitHub workflow, add the following step:
- uses: drew2a/ai-review@v1
env:
LLM_MODEL: gpt-4o
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
debug: false
add_review_resolution: false
add_joke: false
author_customization: |
torvalds: "This is an experienced developer. Focus on architecture and design patterns."
defunkt: "This is a junior developer. Provide educational feedback and explanations."name: AI Code Review
on: [ pull_request ]
permissions:
pull-requests: write
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: drew2a/ai-review@v1
env:
LLM_MODEL: ${{ secrets.LLM_MODEL }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# Add other env vars required by litellm for your specific provider
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
debug: true
add_review_resolution: false
add_joke: falseThe author_customization parameter allows you to customize the review behavior based on the PR author's GitHub username. This is useful for providing different types of feedback for team members with different experience levels or roles.
The customization is provided as YAML using actual GitHub usernames:
torvalds: "Custom review guidance for this user"
defunkt: "Different guidance for another user"Here's an example for a team with users who get customized behavior:
author_customization: |
torvalds: "Use a more friendly manner since they're beginners. Give more examples and explanations to help them learn."
defunkt: "Use a super formal tone and provide low-level grounding. Focus on technical precision and detailed analysis."You can also organize by roles using GitHub usernames:
author_customization: |
torvalds: "Focus on architectural decisions and design patterns. This developer prefers concise, high-level feedback."
defunkt: "Provide educational explanations and learning opportunities. Focus on best practices and code quality fundamentals."
octocat: "Be welcoming and provide clear explanations. Focus on project conventions and coding standards."- uses: drew2a/ai-review@v1
with:
# ... other parameters ...
author_customization: |
torvalds: "Focus on performance and security concerns"
defunkt: "Educational feedback welcomed"Released under the MIT License.