A GitHub Action that automatically reviews Pull Requests using Google's Gemini AI and posts intelligent code review comments.
- 🤖 AI-Powered Reviews: Uses Google Gemini AI for intelligent code analysis
- 📝 Automatic Comments: Posts review comments directly on PRs
- 🔍 Diff Analysis: Analyzes the complete diff of PR changes
- ⚡ Fast Processing: Quick turnaround on review generation
- 🔧 Easy Setup: Simple configuration with minimal setup required
- A Google AI API key (for Gemini access)
- GitHub repository with Actions enabled
- Proper permissions for the GitHub token to comment on PRs
- Visit Google AI Studio
- Create an account or sign in
- Generate an API key for Gemini
- Copy the API key for use in the next step
Add the following secrets to your GitHub repository:
- Go to your repository → Settings → Secrets and variables → Actions
- Add a new repository secret:
- Name:
GEMINI_API_KEY - Value: Your Google AI API key
- Name:
Create .github/workflows/pr-review.yml in your repository:
name: PR Review
on:
pull_request:
types: [opened, synchronize]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Auto PR Review
uses: ikeshav26/auto_pr_reviewer@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}Once set up, the action will automatically:
- Trigger on new PRs or when PRs are updated
- Analyze the diff of all changes in the PR
- Generate an intelligent review using Gemini AI
- Post the review as a comment on the PR
The action requires the following permissions:
contents: read- To read the repository contentpull-requests: write- To comment on pull requestsissues: write- To create issue comments (PRs are issues)
| Variable | Required | Description |
|---|---|---|
GITHUB_TOKEN |
Yes | Automatically provided by GitHub Actions |
GEMINI_API_KEY |
Yes | Your Google AI API key for Gemini access |
| Input | Required | Description |
|---|---|---|
GEMINI_API_KEY |
Yes | Google AI API key for accessing Gemini |
The AI reviewer will analyze your code changes and provide feedback such as:
- Code quality improvements
- Potential bugs or issues
- Best practice suggestions
- Security considerations
- Performance optimization tips
-
"No PR found" error
- Ensure the workflow is triggered on
pull_requestevents - Check that the workflow file is in the correct location
- Ensure the workflow is triggered on
-
Permission denied errors
- Verify that the
GITHUB_TOKENhas proper permissions - Ensure the workflow has
pull-requests: writepermission
- Verify that the
-
Gemini API errors
- Check that your
GEMINI_API_KEYis valid and not expired - Ensure you have sufficient API quota
- Check that your
To enable debug logging, add this to your workflow:
- name: Auto PR Review
uses: ikeshav26/auto_pr_reviewer@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
ACTIONS_RUNNER_DEBUG: true- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the ISC License.
Keshav Gilhotra
- Initial release with Gemini AI integration
- Automatic PR review and commenting functionality
- Support for diff analysis and intelligent feedback
If you encounter any issues or have questions:
- Check the troubleshooting section
- Open an issue in this repository
- Provide detailed information about the error and your setup
⭐ If you find this action helpful, please give it a star!