ai-codereviewer/README.md

71 lines
2.5 KiB
Markdown
Raw Permalink Normal View History

2023-03-22 21:26:59 +00:00
# AI Code Reviewer
2023-03-22 21:16:13 +00:00
2023-03-22 23:11:36 +00:00
AI Code Reviewer is a GitHub Action that leverages OpenAI's GPT-4 API to provide intelligent feedback and suggestions on
your pull requests. This powerful tool helps improve code quality and saves developers time by automating the code
review process.
2023-03-22 21:26:59 +00:00
## Features
- Reviews pull requests using OpenAI's GPT-4 API.
- Provides intelligent comments and suggestions for improving your code.
- Filters out files that match specified exclude patterns.
- Easy to set up and integrate into your GitHub workflow.
## Setup
2023-03-22 23:11:36 +00:00
1. To use this GitHub Action, you need an OpenAI API key. If you don't have one, sign up for an API key
at [OpenAI](https://beta.openai.com/signup).
2023-03-22 21:26:59 +00:00
2023-03-22 23:11:36 +00:00
2. Add the OpenAI API key as a GitHub Secret in your repository with the name `OPENAI_API_KEY`. You can find more
information about GitHub Secrets [here](https://docs.github.com/en/actions/reference/encrypted-secrets).
2023-03-22 21:26:59 +00:00
2023-03-22 23:11:36 +00:00
3. Create a `.github/workflows/main.yml` file in your repository and add the following content:
2023-03-22 21:26:59 +00:00
```yaml
name: AI Code Reviewer
on:
pull_request:
types:
- opened
- synchronize
2023-03-22 23:12:24 +00:00
permissions: write-all
2023-03-22 21:26:59 +00:00
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
2023-03-22 23:12:24 +00:00
uses: actions/checkout@v3
2023-03-22 21:26:59 +00:00
- name: AI Code Reviewer
uses: your-username/ai-code-reviewer@main
with:
2023-03-22 23:11:36 +00:00
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2023-03-22 21:26:59 +00:00
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
2023-07-07 20:35:48 +00:00
OPENAI_API_MODEL: "gpt-4" # Optional: defaults to "gpt-4"
2023-03-22 21:26:59 +00:00
exclude: "**/*.json, **/*.md" # Optional: exclude patterns separated by commas
```
2023-03-22 23:11:36 +00:00
4. Replace `your-username` with your GitHub username or organization name where the AI Code Reviewer repository is
located.
2023-03-22 21:26:59 +00:00
2023-03-22 23:11:36 +00:00
5. Customize the `exclude` input if you want to ignore certain file patterns from being reviewed.
2023-03-22 21:26:59 +00:00
2023-03-22 23:11:36 +00:00
6. Commit the changes to your repository, and AI Code Reviewer will start working on your future pull requests.
2023-03-22 21:26:59 +00:00
## How It Works
2023-03-22 23:11:36 +00:00
The AI Code Reviewer GitHub Action retrieves the pull request diff, filters out excluded files, and sends code chunks to
the OpenAI API. It then generates review comments based on the AI's response and adds them to the pull request.
2023-03-22 21:26:59 +00:00
## Contributing
2023-03-22 23:11:36 +00:00
Contributions are welcome! Please feel free to submit issues or pull requests to improve the AI Code Reviewer GitHub
Action.
2023-03-22 21:26:59 +00:00
Let the maintainer generate the final package (`yarn build` & `yarn package`).
2023-07-31 15:36:20 +00:00
2023-03-22 21:26:59 +00:00
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.