Skip to main content

Automated PR code reviews with GitHub, GPT-4, and Google Sheets best practices

Workflow preview

Workflow preview
100%
Automated PR code reviews with GitHub, GPT-4, and Google Sheets best practices preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

AI Agent Code Review for GitHub Pull Requests Description: This n8n workflow automates the process of reviewing code changes in GitHub pull requests using an OpenAI powered agent. It connects your ...

Best for

  • DevOps automation workflows
  • AI Summarization automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.githubtrigger, n8n-nodes-base.httprequest, n8n-nodes-base.code, n8n-nodes-base.github, n8n-nodes-base.googlesheetstool, n8n-nodes-base.stickynote, @n8n/n8n-nodes-langchain.agent

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Jihene.

Original n8n.io source

1.1 Workflow description

Title
Automated PR code reviews with GitHub, GPT-4, and Google Sheets best practices
Workflow name
Automated PR code reviews with GitHub, GPT-4, and Google Sheets best practices

AI-Agent Code Review for GitHub Pull Requests

Description:

This n8n workflow automates the process of reviewing code changes in GitHub pull requests using an OpenAI-powered agent.

It connects your GitHub repo, extracts modified files, analyzes diffs, and uses an AI agent to generate a code review based on your internal code best practices (fed from a Google Sheet).

It ends by posting the review as a comment on the PR and tagging it with a visual label like βœ… Reviewed by AI.

πŸ”§ What It Does

  1. Triggered on PR creation

  2. Extracts code diffs from the PR

  3. Formats and feeds them into an OpenAI prompt

  4. Enriches the prompt using a Google Sheet of Swift best practices

  5. Posts an AI-generated review as a comment on the PR

  6. Applies a PR label to visually mark reviewed PRs

βœ… Prerequisites

Before deploying this workflow, ensure you have the following:

  • n8n Instance (Self-hosted or Cloud)
  • GitHub Repository with PR activity
  • OpenAI API Key for GPT-4o, GPT-4-turbo, or GPT-3.5
  • GitHub OAuth App (or PAT) connected to n8n to post comments and access PR diffs
  • (Optional) Google Sheets API credentials if using the code best practices lookup node.

βš™οΈ Setup Instructions

1. Import the Workflow in n8n, click on Workflows β†’ Import from file or JSON Paste or upload the JSON code of this template

2. Configure Triggers and Connections

πŸ” GitHub Trigger
  • Node: PR Trigger
  • Repository: Select the GitHub repo(s) to monitor
  • Events: Set to pull_request
  • Auth: Use GitHub OAuth2 credentials
πŸ“₯ HTTP Request

Node: Get file's Diffs from PR

No authentication needed; it uses dynamic path from trigger

🧠 OpenAI Model
  • Node: OpenAI Chat Model

  • Model: Select gpt-4o, gpt-4-turbo, or gpt-3.5-turbo

  • Credential: Provide your OpenAI API Key

πŸ§‘β€πŸ’» Code Review Agent

Node : Code Review Agent Connected to OpenAI and optionally to tools like Google Sheets

πŸ’¬ GitHub Comment Poster

Uses GitHub API to post review comments back on PR Node: GitHub Robot Credential: Use the agent Github account (OAuth or PAT) Repo : Pick your owen Github Repository

🏷️ PR Labeler (optional)

Adds label ReviewedByAI after successful comment

Node: Add Label to PR Label : you ca customize the label text of your owen tag.

πŸ“Š Google Sheet Best Practices config (optional)

Connects to a Google Sheet for coding guideline lookups, we can replace Google sheet by another tool or data base

  • First prepare your best practices list with the clear description and the code bad/good examples
  • Add al the best practices in your Google Sheet
  • Configure the Code Best Practices node in the template :
Credential : Use your Google Sheet account by OAuth2
URL : Add your Google Sheet document URL
Sheet : Add the name of the best practices sheet

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 2 - PR Trigger

Type / Role
n8n-nodes-base.githubTrigger - githubTrigger
Config choices
Version 1

Block 3 - Get file's Diffs from PR

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 4 - Create target Prompt from PR Diffs

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 5 - GitHub Robot

Type / Role
n8n-nodes-base.github - github
Config choices
Version 1.1

Block 6 - Add Label to PR

Type / Role
n8n-nodes-base.github - github
Config choices
Version 1

Block 7 - Code Best Practices

Type / Role
n8n-nodes-base.googleSheetsTool - googleSheetsTool
Config choices
Version 4.5

Block 8 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 9 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 10 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Code Review Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.9

Block 13 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Automated PR code reviews with GitHub, GPT-4, and Google Sheets best practices
Complexity intermediate
Nodes 14
Categories DevOps, AI Summarization
Author Jihene
Published 30 Apr 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3804/3804.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Automated PR code reviews with GitHub, GPT-4, and Google Sheets best practices do?

AI Agent Code Review for GitHub Pull Requests Description: This n8n workflow automates the process of reviewing code changes in GitHub pull requests using an OpenAI powered agent. It connects your ...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your DevOps, AI Summarization use case.