💸Save up to $132K/month in CI costs!👉 Try Free
Skip to main content
← Back to workflows

How to Use GitHub Action for AI Code Review

freeedcom/ai-codereviewer -
GitHub Action
Support gpt-4-1106-preview
576
Contributors
Contributor - villesauContributor - lfsevergniniContributor - felixAnhalt
Categories

Optimize Your CI/CD Pipeline

Get instant insights into your CI/CD performance and costs. Reduce build times by up to 45% and save on infrastructure costs.

45% Faster Builds
60% Cost Reduction
Usage
name: 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: AI Code Reviewer
uses: your-username/ai-code-reviewer@main

ai-codereviewer logo

ai-codereviewer

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.


freeedcom/ai-codereviewer a GitHub Action to utilize the OpenAI GPT-4 API for intelligent feedback and suggestions on your pull requests. You now have a tool to automate code review so that the necessary quality is met by your code, which will also save developers time.

Pull request reviews utilize the GPT-4 API from OpenAI, offering intelligent insights into the code through comments and suggestions for improvement. Additionally, the tool can exclude files matching a specified pattern, ensuring that only relevant files are reviewed. The setup and integration process is straightforward, seamlessly fitting into your existing GitHub flow.

How It Works

An AI Code Reviewer GitHub Action would execute the OpenAI Model, take a diff of the pull request, apply the exclusions of files, and send these chunks of code to the OpenAI API. Afterward, the AI would reply to the review comments and add them to the pull request.

The example YAML above adds the AI Code Reviewer to your pipeline, and this way, it standardizes your reviews, among other benefits. This can not only improve code quality but also maintain consistency.

Security Issues

Add your GITHUB_TOKEN and OPENAI_API_KEY to the secrets in your repository's GitHub so you prevent unauthorized entry to your GitHub and OpenAI account.

Version Control

This will adhere to semantic versioning principles so that using a stable version of AI Code Reviewer keeps the updates predictable and stable.

Flexibility and Customization

This makes such an action very flexible in its setup—for example, it allows one to exclude patterns of files or to set a concrete OpenAI API model, thus rendering it easily adaptable to most project needs.