Skip to content

AI Code Reviewer: Enhance your GitHub workflow with AI-powered code review! Get intelligent feedback and suggestions on pull requests using OpenAI's GPT-4 API, improving code quality and saving developers time.

License

Notifications You must be signed in to change notification settings

masroorposh10/ai-codereviewer

 
 

Repository files navigation

AI Code Reviewer

AI Code Reviewer is a GitHub Action that leverages Azure OpenAI 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.

Features

  • Reviews pull requests using Azure OpenAI 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

  1. Add the Azure OpenAI API key and Endpoint as a GitHub Secret in your repository with the name AZURE_OPENAI_API_KEY and AZURE_OPENAI_API_ENDPOINT. You can find more information about GitHub Secrets here.

  2. Create a .github/workflows/code_review.yml file in your repository and add the following content:

name: Code Review with OpenAI
on:
  pull_request:
    types:
      - opened
      - synchronize
permissions: write-all
jobs:
  code_review:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
      - name: Code Review
        uses: masroorposh10/ai-codereviewer@main
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
          AZURE_OPENAI_API_ENDPOINT: ${{secrets.AZURE_OPENAI_API_ENDPOINT}}
          AZURE_OPENAI_API_MODEL: "gpt-4-v0613"
          exclude: "yarn.lock,dist/**"
  1. In the AZURE_OPENAI_API_MODEL name it with your deployment name.

  2. Customize the exclude input if you want to ignore certain file patterns from being reviewed.

  3. Commit the changes to your repository, and AI Code Reviewer will start working on your future pull requests.

How It Works

The AI Code Reviewer GitHub Action retrieves the pull request diff, filters out excluded files, and sends code chunks to the Azure OpenAI API. It then generates review comments based on the AI's response and adds them to the pull request.

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests to improve the AI Code Reviewer GitHub Action.

Let the maintainer generate the final package (yarn build & yarn package).

License

This project is licensed under the MIT License. See the LICENSE file for more information.

About

AI Code Reviewer: Enhance your GitHub workflow with AI-powered code review! Get intelligent feedback and suggestions on pull requests using OpenAI's GPT-4 API, improving code quality and saving developers time.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 88.6%
  • JavaScript 11.4%