Skip to main content

Deploy n8n workflows with GitHub-based version control

Workflow preview

Workflow preview
100%
Deploy n8n workflows with GitHub-based version control preview
Open on n8n.io

1. Workflow Overview

Say goodbye to messy JSON exports. Treat your n8n automations like real software with a built in CI/CD pipeline. Manually moving workflows between testing and production is a recipe for versioning ...

Best for

  • DevOps automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.github, n8n-nodes-base.httprequest, n8n-nodes-base.set, n8n-nodes-base.if, n8n-nodes-base.code, n8n-nodes-base.formtrigger, n8n-nodes-base.n8n, n8n-nodes-base.errortrigger

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Deploy n8n workflows with GitHub-based version control
Workflow name
Deploy n8n workflows with GitHub-based version control

Say goodbye to messy JSON exports. Treat your n8n automations like real software with a built-in CI/CD pipeline.

Manually moving workflows between testing and production is a recipe for versioning nightmares, overwritten data, and broken webhooks. This workflow acts as a centralized DevOps Control Center, allowing you to back up, version-control, and deploy your automations directly from a custom n8n form. It doesn't just push code; it validates changes, prevents duplicate commits, routes to the correct environment, and orchestrates production deployments automatically.

How it works

The workflow operates in four synchronized stages:

  1. Form-Driven Trigger & Sanitization: Initiates via a custom n8n form requesting the local Workflow ID, the target environment (Sandbox or Production), and a Git commit message. It fetches the local workflow and intelligently scrubs instance-specific metadata while preserving nodes, connections, and core settings.
  2. Smart GitHub Versioning: Queries the GitHub API to fetch the existing file SHA and compares the raw content. If the workflow hasn't changed since the last deployment, it safely skips the commit to prevent cluttering your Git history.
  3. Environment Routing: Data fans out based on the chosen path:
  • Sandbox: Pushes the sanitized JSON to a /sandbox/ repository folder and safely terminates, acting as a clean, versioned backup.
  • Production: Pushes to the /production/ repository folder, connects to the target Prod n8n instance via API, checks if the workflow already exists, and seamlessly creates or updates it.
  1. Auto-Activation & Error Catching: Automatically toggles the newly deployed workflow to "Active" on the production server. A global Error Trigger stands guard in the background to catch any API failures, formatting a clean, actionable error response with the execution ID and failed node name.

Key Benefits

  • Zero-Friction Deployments: Replaces manual file downloads and UI importing with a simple 1-click CI/CD form.
  • Clean Git History: Built-in hashing and comparison logic ensures you only commit actual structural or code changes, avoiding empty commits.
  • Multi-Environment Support: Safely separates work-in-progress (Sandbox) from live, revenue-generating automations (Production).
  • Safe & Monitored: The workflow scrubs harmful static data before pushing, and the global error catcher ensures broken deployments are flagged immediately.

Setup

  1. Credentials: Add your GitHub OAuth2 (or Personal Access Token) and your n8n API credentials. You will need one n8n credential for local read access, and one for your target Production server.
  2. Repository Config: Open the Repo Config node and replace the placeholder text with your specific repoOwner, repoName, and target branch (e.g., main).
  3. Production Mapping: Ensure the Find Workflow on Prod, Create on Prod Server, and Update on Prod Server nodes are explicitly configured to use your Production n8n API credential.
  4. Activate: Turn the workflow on, open the Form Trigger URL, and start deploying!

Who this is for

  • Automation Agencies & MSPs managing complex multi-tenant or multi-server client environments.
  • Enterprise IT Teams requiring strict version control, code backups, and compliance for their automations.
  • Power Users running a segmented n8n architecture (Dev/Staging/Prod) who want to stop manually migrating workflows.

Required APIs & Credentials

  • Microsoft GitHub: OAuth2 API or Personal Access Token (Requires repo contents Read/Write permissions).
  • n8n API: Local instance (Read) and Production instance (Read/Write/Activate).

How to customise it

  • Add Staging Environments: Easily expand the Environment mapping code to include a 'Staging' or 'UAT' deployment branch.
  • Custom Notifications: Attach a Slack or Microsoft Teams node at the end of the Build Success Response to notify your DevOps channel whenever a new version goes live.

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 - Update GitHub File

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

Block 2 - Get GitHub File SHA

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

Block 3 - No Changes Detected

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 4 - Content Changed?

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

Block 5 - Code in JavaScript

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

Block 6 - DevOps Form

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

Block 7 - Build File Context

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

Block 8 - Repo Config

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 9 - Fetch Local Workflow

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

Block 10 - Is Production Deploy?

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

Block 11 - GitHub File Exists?

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

Block 12 - Build Error Response

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 13 - Workflow Error Trigger

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

Block 14 - Build Success Response

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 15 - Activate on Production

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

Block 16 - Create on Prod Server

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

Block 17 - Update on Prod Server

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

Block 18 - Workflow Exists on Prod?

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

Block 19 - Resolve Prod Workflow ID

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

Block 20 - Find Workflow on Prod

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

Block 21 - Sandbox Backup Complete

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 22 - Create GitHub File

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

Block 23 - Sticky Note

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

Block 24 - Sticky Note1

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

Showing the first 24 of 29 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Deploy n8n workflows with GitHub-based version control
Complexity advanced
Nodes 29
Categories DevOps
Author Mychel Garzon
Published 18 May 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/15795/15795.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 Deploy n8n workflows with GitHub-based version control do?

Say goodbye to messy JSON exports. Treat your n8n automations like real software with a built in CI/CD pipeline. Manually moving workflows between testing and production is a recipe for versioning ...

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 use case.