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.
Find a file
2024-09-04 17:15:58 -04:00
.devcontainer Formatting 2024-09-04 17:15:58 -04:00
.github Formatting 2024-09-04 17:15:58 -04:00
act Formatting 2024-09-04 17:15:58 -04:00
dist Formatting 2024-09-04 17:15:58 -04:00
src Formatting 2024-09-04 17:15:58 -04:00
.gitignore Fixed issues around the Azure OpenAI API in the code reviewer 2024-09-04 17:14:09 -04:00
action.yml Fixed issues around the Azure OpenAI API in the code reviewer 2024-09-04 17:14:09 -04:00
LICENCE add proper readme 2023-03-22 23:35:23 +02:00
package-lock.json Fixed issues around the Azure OpenAI API in the code reviewer 2024-09-04 17:14:09 -04:00
package.json Fixed issues around the Azure OpenAI API in the code reviewer 2024-09-04 17:14:09 -04:00
README.md updating the docs and yaml 2024-08-15 09:51:46 -04:00
renovate.json Formatting 2024-09-04 17:15:58 -04:00
tsconfig.json initial commit 2023-03-22 23:16:13 +02:00
yarn.lock Fixed issues around the Azure OpenAI API in the code reviewer 2024-09-04 17:14:09 -04:00

CDS AI Code Reviewer

CDS 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.

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

  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.

  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.

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

name: CDS AI Code Reviewer

on:
  pull_request:
    types:
      - opened
      - synchronize
permissions: write-all
jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v3

      - name: CDS AI Code Reviewer
        uses: cds-snc/cds-ai-code-reviewer@main
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # The GITHUB_TOKEN is there by default so you just need to keep it like it is and not necessarily need to add it as secret as it will throw an error. [More Details](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret)
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          OPENAI_API_MODEL: "gpt-4" # Optional: defaults to "gpt-4"
          exclude: "**/*.json, **/*.md" # Optional: exclude patterns separated by commas
  1. Customize the exclude input if you want to ignore certain file patterns from being reviewed.

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

How It Works

The CDS 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.

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests to improve the CDS 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.