Review GitHub pull requests and label them using OpenAI GPT-4o-mini and Slack
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?
DevOps Engineers** looking to standardize PR triage. Team Leads** who want to provide instant feedback to developers. Open Source Maintainers** managing high volumes of contributions. Development Teams** aiming to reduce manual overhead in code reviews.
How it works / What it does
Trigger: The workflow starts via a GitHub PR Webhook when a pull request is opened or synchronized. 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. Analysis: A Code Node categorizes the changes (e.g., size labels like size/S or size/L). AI Review: The AI Agent (powered by OpenAI) analyzes the code diff to generate a quality score, summary, and specific strengths/concerns. 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. Reporting: All review data is logged into Google Sheets for long-term tracking and analytics.
Requirements
GitHub Account:** OAuth credentials with repository access. OpenAI API Key:** For the Chat Model (recommends GPT-4o-mini or higher). Slack Workspace:** A bot token to post to the #code-reviews channel. Google Sheets:** A spreadsheet with headers matching the PR metadata.
How to set up
GitHub Webhook: Configure your GitHub repository to send "Pull request" events to the Webhook URL provided by this workflow. Credentials: Authenticate your GitHub, OpenAI, Slack, and Google Sheets accounts in their respective nodes. Google Sheets: Select your target Spreadsheet and Sheet name in the "Log to Sheets" node. Slack: Ensure the Slack bot is invited to the channel specified in the "Notify Slack" node.
How to customize
AI Prompt:* Modify the "System Message" in the AI Code Reviewer* node to reflect your team's specific coding standards or preferred review tone. Labeling Logic:** Edit the "Analyze File Changes" node to add custom labels based on file paths (e.g., frontend, documentation). Review Logic:* Add an If Node* after the AI analysis to only auto-approve PRs with a quality score higher than 90.
Related Templates
Use OpenRouter in n8n versions <1.78
What it is: In version 1.78, n8n introduced a dedicated node to use the OpenRouter service, which lets you to use a lot...
Task Deadline Reminders with Google Sheets, ChatGPT, and Gmail
Intro This template is for project managers, team leads, or anyone who wants to automatically remind teammates of tasks ...
🤖 Build Resilient AI Workflows with Automatic GPT and Gemini Failover Chain
This workflow contains community nodes that are only compatible with the self-hosted version of n8n. How it works This...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments