Reviewed-on: #9
Code Review Action
Code Review Action is a Gitea/GitHub Action that automatically reviews pull requests using one or multiple AI Large Language Models (LLMs). It analyzes code diffs and provides both granular file-level feedback as well as an overall review summary.
Table of Contents
Features
- Single Chunk Review: The action analyzes each file’s diff and provides line-specific suggestions (if applicable).
- Full Context Review: Analyzes entire file contents plus diffs, giving an overall code review summary.
- Configurable Models: Supports multiple LLM providers (OpenAI, Anthropic, Google, etc.) via model prefixes (
gpt-,claude-,gemini-,deepseek-). - Exclusion Filters: Skip certain files (e.g.
.yaml) based on matching patterns.
Usage
- Add this Action to your repository’s workflow (e.g.,
.github/workflows/pr-review.ymlor.gitea/workflows/pr-review.ymlin Gitea). - Provide required inputs (API keys, model names, etc.) as shown below.
- Submit a pull request against the repository. The Action will automatically run on PR events (
openedorsynchronize) and post review comments.
Note
: This action is intended primarily for use with Gitea.
Inputs
| Input Name | Required | Default | Description |
|---|---|---|---|
access-token |
Yes | - | The Gitea or GitHub token with permissions to read and comment on PRs (e.g., $GITHUB_TOKEN). |
full-context-model |
Yes | gpt-4o |
The model to use for the full context review. Supports prefixes: gpt-, claude-, gemini-, etc. |
full-context-api-key |
Yes | - | The API key to use with the specified full-context model. |
single-chunk-model |
Yes | gpt-4o |
The model to use for single-chunk review (file-by-file). |
single-chunk-api-key |
Yes | - | The API key to use with the specified single-chunk model. |
exclude-files |
No | *.yml,*.yaml |
Comma-separated file pattern(s) to exclude from diffs (e.g., *.md,*.yaml). |
Example Workflow
Below is an example workflow file you can place in your repository (e.g., .github/workflows/pr-review.yml on GitHub or .gitea/workflows/pr-review.yml on Gitea). Adjust the version/tag/branch reference as needed.
name: PR Review
on:
pull_request:
types: [opened, synchronize]
permissions:
contents: read
pull-requests: write
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: AI Code Review
uses: YOUR-ORG/CODE-REVIEW-ACTION@v1
with:
access-token: ${{ secrets.ACCESS_TOKEN }}
full-context-model: "gpt-4o"
full-context-api-key: ${{ secrets.OPENAI_API_KEY }}
single-chunk-model: "claude-3-5-sonnet-20240620"
single-chunk-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
exclude-files: "*.md,*.yaml"
Explanation
on.pull_request.types: The workflow triggers when a pull request is opened or synchronized (i.e., new commits pushed).permissions: We grantreadpermission to contents andwriteto pull-requests so the Action can post review comments.steps.uses: References your published action. ReplaceYOUR-ORG/CODE-REVIEW-ACTION@v1with the actual owner/repo name and a valid version tag (e.g.,@mainor@v1).with: Provides the necessary inputs.access-token: Must be a secret that can post to PRs (e.g.,$GITHUB_TOKENor a personal access token on Gitea).full-context-model&single-chunk-model: Choose which models to use (OpenAI GPT, Anthropic Claude, Google PaLM, etc.).full-context-api-key&single-chunk-api-key: Corresponding API keys for each model.exclude-files: If you want to skip reviewing certain file types, specify patterns here (default is*.yml,*.yaml).
License
This project is available under the MIT License. Feel free to modify and adapt to your own needs.
If you have any questions, issues, or feedback, please open an issue in this repository. Happy reviewing!
Languages
Python
100%