A friend that can help you review PRs when there are no one else to help you.
This is a very simple bot that uses the OpenAI GPT40 model to generate a review message for a PR.
Reviewabot only knows about the PR diff. It does have the entire repository as a context like GitHub Copilot might have.
There might be better solutions out there. And I am sure that GitHub is working on a CodeReview Bot that will be able to do this better.
Go to Github and create a new user account that will be used to review the PRs. Add the new user as a collaborator to your repository.
Under settings for the new user account, create a new Personal Access Token that has access to source and read/write to Pull Requests.
Either:
- Go to OpenAI and create an API key.
- Go to the Azure Portal and create an OpenAI resource and deploy the gpt-4o model. Get the API key and the endpoint.
Create a new GitHub Action in your repository that runs the Reviewabot. Use the action from the Marketplace.
https://github.com/marketplace/actions/reviewabot
Make sure the GitHub action is triggered in a workflow. See the description in Reviewabot Marketplace.
Reviewabot will always approve your PR.
Download the source and run the following command in the root of the project:
dotnet run --owner={repo_owner} --repo={repository} --prnumber={pr-number} --githubpat={github-pat} --openaikey={apenai-api-key}Here is an example where we review PR #4 in the GitHub repository https://github.com/simon-k/hello-api/.
The GitHub user that does the review is represented by it's PAT YYY. We use the OpenAI API key XXX to generate the review with GPT4o.
dotnet run --owner=simon-k --repo=hello-api --prnumber=4 --githubpat=thisisadummypat --openaikey=thisisadummykeyAnd the same example with Azure OpenAI:
dotnet run --Owner=simon-k --Repo=hello-api --PrNumber=4 --GitHubPat=YYY --OpenAiKey=XXX --AzureOpenAiKey=thisisadummykey --AzureOpenAiEndpoint=https://yourresourcename.openai.azure.com| Argument | Description | Required |
|---|---|---|
| Owner | The owner of the repository | Yes |
| Repo | The name of the repository | Yes |
| PrNumber | The PR number | Yes |
| GitHubPat | The Personal Access Token for the GitHub Account that makes the review | Yes |
| OpenAiKey | The key for the OpenAI API | No |
| AzureOpenAiKey | The key for the Azure OpenAI API | No |
| AzureOpenAiEndpoint | The endpoint for the Azure OpenAI API | No |
You must provide either an OpenAI key or an Azure OpenAI key together with an Azure OpenAI endpoint.
Contact me. I would like your input. Or just create a PR with your improvements.
Create a new release in GitHub. The GitHub Release Action generate the binaries and attach them to the release.
- Make instructions configurable from a markdown file
- Use Spectre Console to make things nice to look at
- Use a better tool for parsing command line arguments
- Create some tests
- Add OpenSSF Scorecard
See the LICENSE file for license rights and limitations (MIT).
If you use this for anything cool, please let me know. I would love to hear about it 🫶.
