Skip to content
KhangHo10Public

About

A hands-on workshop project that builds an AI-powered pull request reviewer using GitHub Actions and the LLM API. When a pull request is opened or updated, the bot automatically fetches the diff, sends it to LLM for review, and posts the feedback as a comment on the PR — no servers, no webhooks, no hosting required.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

17 Commits

Folders and files

Repository files navigation

AI Workshop: Building a PR Review Bot

AI-powered PR review using GitHub Actions and an LLM. This project fetches the PR diff, sends it to the model, and posts the review as a PR comment.

Gemini is used here because it has a free tier, but the same setup can work with other LLMs after updating the API client and secrets.

Example PR review comment generated by the bot

Resources

How it works

  1. A PR (pull request) is opened or updated.
  2. GitHub Actions runs the workflow.
  3. The script fetches the diff from GitHub.
  4. The diff is sent to the model for review.
  5. The bot formats the result and posts it as a PR comment.

Project structure

pr-bot/
├── .github/workflows/pr-review.yml
├── scripts/review.py
├── requirements.txt
├── README.md
├── tictactoe.html
└── .gitignore

Prerequisites

  • GitHub account and repo with Actions enabled
  • LLM API key (Gemini for this example)
  • Python 3.11+

Setup

1. Clone the repo for local exploration

If you just want to look at the project locally:

git clone git@github.com:KhangHo10/pr-bot.git
cd pr-bot

If you want the bot to actually run on a pull request, use your own repository or fork this repo first. Without write access, you cannot push to this repo or open a PR against it.

2. Install dependencies

pip install -r requirements.txt

3. Add the GitHub secret

In the repository where the bot will run, add a secret named GEMINI_API_KEY in GitHub Actions settings.

4. Create a branch and open a PR

Create a new branch in that repository, make a change, and open a pull request. The workflow in .github/workflows/pr-review.yml runs automatically when a PR is opened, synchronized, or reopened.

on:
  pull_request:
    types: [opened, synchronize, reopened]

GitHub Actions does not run from your local clone. It runs in the GitHub repository that contains the PR.

5. Run locally (optional)

You can test the script locally before pushing a PR.

export REPO="owner/repo-name"
export PR_NUMBER="12"
export GITHUB_TOKEN="your_github_token"
export GEMINI_API_KEY="your_gemini_api_key"
python scripts/review.py

Customize for another repo

Notes

  • This is a review assistant, not a replacement for human judgment.
  • Keep API keys in GitHub Secrets.
  • Make sure the repo has permission to comment on pull requests.

License

This project is provided as a workshop/demo example. You are free to reuse and adapt it for your own repositories.

About

A hands-on workshop project that builds an AI-powered pull request reviewer using GitHub Actions and the LLM API. When a pull request is opened or updated, the bot automatically fetches the diff, sends it to LLM for review, and posts the feedback as a comment on the PR — no servers, no webhooks, no hosting required.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages