![AI Code Review Banner](https://private-user-images.githubusercontent.com/12605300/239670824-e4a0bfb6-b1f4-4dd5-a2d7-7d68711531e9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI2NzI2OTEsIm5iZiI6MTcyMjY3MjM5MSwicGF0aCI6Ii8xMjYwNTMwMC8yMzk2NzA4MjQtZTRhMGJmYjYtYjFmNC00ZGQ1LWEyZDctN2Q2ODcxMTUzMWU5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODAzVDA4MDYzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdhMjc3ZGY5YWI4MWE0NGQyNDZhNDhlNmY5YTIxZDBjYTZkZGY0ZDQyOTQ3MmU3OWUwZjQzOGI2ZWUwNGNmZTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.RRpNondGbI21YK0u0CWAATiMp7tZPfiCaBfDh2uFeCI)
Let AI do code review for you! Demo
This app is calling OpenAI chatGPT API to do code review for you.
GitHub App | GitHub Action | Self-host Instruction
- Install GitHub App for you repository - GitHub App - AI Code Review
- Create a pull request in your repository
-
Go to Settings -> Secrets and variables -> Actions -> New repository secret
-
Create a repository secret named
OPENAI_API_KEY
and fill it with your API key -
Add following configurtion in your
.github/workflows/pr-code-review.yml
name: Code Review permissions: contents: read pull-requests: write on: pull_request: types: [opened, synchronize] jobs: code-review: runs-on: ubuntu-latest steps: - uses: Louis-7/ai-code-review@v0.4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} PATH_TO_EXCLUDE: action/**/*, package-lock.json, package.json MAX_PATCH_PER_FILE: 2000 MAX_FILE_PER_PR: 20
-
GITHUB_TOKEN
andOPENAI_API_KEY
are required parameter. Others are optional. You can get all available options in the .env.action.example -
Create a pull request in your repository
You can also host the code reviewer by your self. Just follow the Dev section.
The application is built on Probot.
# Install dependencies
npm install
# add environment variables
cp .env.example .env
# build app
npm run build
# Run the bot
npm start
Learn more about Probot configuration.
# build node.js app
npm run build
# build GitHub Action
npm run build:action
# build deployable azure function
npm run build:function
You can also build docker image to deploy.
# 1. Build container
docker build -t protagonist-bot .
# 2. Start container
docker run -e APP_ID=<app-id> -e PRIVATE_KEY=<pem-value> protagonist-bot
GPL 3.0 © 2023 Louis Liu