🎯 Review GitHub pull requests and label them using OpenAI GPT-4o-mini and Slack

296 views · 🎯 AI Summarization & Classification

💡 Pro Tip — If you need GitHub data beyond what the REST API gives you, ScraperNode has a repository scraper that extracts metadata at scale without token rate limits.

View All Scrapers

Description

Automate GitHub pull request reviews and labeling using OpenAI

This workflow automates the first line of code review for your development team. By leveraging OpenAI, it analyzes pull request diffs, assigns descriptive labels based on change size and category, posts summary comments back to GitHub, and keeps your team informed via Slack.

Who’s it for?

How it works / What it does

  1. Trigger: The workflow starts via a GitHub PR Webhook when a pull request is opened or synchronized.
  2. Data Gathering: It extracts PR metadata and uses the GitHub Node and HTTP Request Node to fetch a list of changed files and the raw code diff.
  3. Analysis: A Code Node categorizes the changes (e.g., size labels like size/S or size/L).
  4. AI Review: The AI Agent (powered by OpenAI) analyzes the code diff to generate a quality score, summary, and specific strengths/concerns.
  5. Action:
    • The GitHub Node updates the PR with relevant labels.
    • An automated review comment is posted to the PR discussion.
    • A summary is sent to a Slack channel.
  6. Reporting: All review data is logged into Google Sheets for long-term tracking and analytics.

Requirements

How to set up

  1. GitHub Webhook: Configure your GitHub repository to send “Pull request” events to the Webhook URL provided by this workflow.
  2. Credentials: Authenticate your GitHub, OpenAI, Slack, and Google Sheets accounts in their respective nodes.
  3. Google Sheets: Select your target Spreadsheet and Sheet name in the “Log to Sheets” node.
  4. Slack: Ensure the Slack bot is invited to the channel specified in the “Notify Slack” node.

How to customize

🔗 Nodes Used

GitHub, Google Sheets, HTTP Request, Slack, Webhook, Filter

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup