A GitHub action uses OpenAI's GPT-4 to perform automated code reviews. When you create a PR, our action will automatically review the code and suggest changes, just like a human code reviewer would.
- Get an API Key from OpenAI
- Add it as a GitHub secret
- Setup an action that runs on every PR
name: 'code-review'
on: # rebuild any PRs and main branch changes
pull_request:
jobs:
code-review:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: gvasilei/AutoReviewer@0.5.1
env:
NODE_OPTIONS: '--experimental-fetch'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
exclude_files: '*.json, *.md, *.yml' # optionally exclude files based on a wildcard expression.
- Or when a label is added
name: 'code-review'
on: # rebuild any PRs and main branch changes
pull_request:
types: [labeled]
jobs:
code-review:
if: ${{ contains( github.event.label.name, 'AutoReview') }}
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: gvasilei/AutoReviewer@0.5.1
env:
NODE_OPTIONS: '--experimental-fetch'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
exclude_files: '*.json, *.md, *.yml' # optionally exclude files based on a wildcard expression.
Parameter | Required | Default | Description |
---|---|---|---|
github_token | True | Necessary for communicating with GitHub. Autogenerated by the GHA | |
openai_api_key | True | OpenAI API key | |
model_name | False | gpt-3.5-turbo | OpenAI ChatModel. Currently supports gpt-4 and gpt-3.5-turbo |
model_temperature | False | 0 | OpenAI model temperature |
exclude_files | False | Provide a wildcard expression to exclude files from code review. For example, *.md will exclude all Markdown files. Multiple expressions are supported via commas, eg *.js, *.cjs |
Using our GitHub action has many benefits, such as:
- Faster code reviews
- More consistent feedback
- Increased productivity
- Improved code quality
- This GitHub Action is still in early development.
- While the action supports both
gpt-4
andgpt-3.5-turbo
,gpt-4
gives much better suggestions.
If you have any ideas or improvements to our GitHub action, feel free to submit a PR. We welcome all contributions!