GitLab Version Control for Customer-Tagged Workflows - n8n Workflow

Automate robust version control for your critical n8n workflow assets using GitLab. This dynamic n8n template organizes backups into customer-specific folders, tracks changes, and prevents unnecessary commits.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Automation Developers: Needing reliable version control for their complex n8n workflow designs.

  • Consulting Agencies: Requiring separate, auditable backup folders for different customer solutions managed within a single n8n instance.

  • DevOps Engineers: Seeking to integrate n8n templates deployment and backup strategies into existing CI/CD pipelines.

  • Anyone who wants high availability and audit trails for their mission-critical n8n assets.

Overview

Maintaining an audit trail and ensuring recoverability for complex automation solutions is crucial. This advanced n8n workflow solves the problem of decentralized workflow management by centralizing all critical n8n workflow assets in a structured GitLab repository.

It features intelligent filtering—only workflows tagged backup-workflows are processed. Furthermore, it analyzes the workflow name for a [customer: NAME] tag to automatically create customer-specific subdirectories, ensuring that customer-related n8n templates are neatly segregated.

By comparing the current n8n workflow JSON against the latest version in GitLab, it avoids excessive commits, only executing an update if a functional change is detected, thus maintaining a clean and efficient Git history. This approach ensures your n8n backups are stable, organized, and easily re-importable.

How it Works

The process begins with an n8n trigger, either manual execution or the daily Schedule Trigger at 03:
00.


  1. Initialization: The Set Global GitLab Variables n8n node defines parameters like the GitLab repository details, branch (main), and the required tag filter (backup-workflows).

  2. Fetching Workflows: The Fetch Workflows from n8n n8n node uses the internal n8n API to retrieve all workflows matching the specified tag, minimizing API traffic and processing time.

  3. Data Normalization: For each retrieved workflow, the Clean & Normalize Workflow Name code n8n node standardizes the [customer: NAME] format. The Prepare Workflow JSON for UI-Compatible Export n8n node then cleans the JSON to ensure it matches the standard UI export, making it perfectly suitable for re-import.

  4. Path Generation: The Prepare GitLab File Path code n8n node constructs the final storage path using the workflow’s stable ID and the extracted customer slug (e.g., workflow_definitions/acme/workflowId.json).

  5. Change Detection: The Fetch Existing File from GitLab n8n node attempts to retrieve the backup. If it fails (new workflow), the flow is redirected to Create New File in GitLab.

  6. Comparison: If the file exists, the Compare Workflow with GitLab Version n8n node performs a strict JSON content comparison. If changes are detected, the Update Existing File in GitLab n8n node commits the change. If no changes are found, the workflow is tagged as unchanged.

  7. Reporting: Finally, all paths converge via the Merge n8n node. The outputs are standardized by the Normalize Backup Output n8n node and summarized by the Summarize Backup Results code n8n node, providing a final recap of created, updated, and unchanged workflows.

Installation Guide

To use this n8n template, follow these steps:


  1. Import: Copy the entire JSON code and import it directly into your n8n instance as a new n8n workflow.

  2. Credentials: You will need two credentials:

n8n API: Configure an internal n8n API credential to allow the workflow to query your list of existing workflows (necessary for the Fetch Workflows from n8n n8n node).
GitLab API: Configure a GitLab credential with api or writerepository permissions for the target repository. This credential will be used by the GitLab n8n node.

  1. Configuration:

Locate the Set Global GitLab Variables n8n node.
Update gitlab
owner, gitlabproject, and gitlabbranch to match your GitLab repository details.
* Ensure the tag_backup value (backup-workflows) is the tag you use to mark critical n8n templates.

  1. Tag Workflows: Navigate to your desired n8n workflow and add the tag backup-workflows (or the custom tag defined in step 3).

  2. Activation: Activate the n8n workflow to enable the scheduled daily backup.

Node Details


  • Schedule Trigger: Acts as the primary n8n trigger, scheduled to run daily at 3 AM to minimize disruption during peak hours.

  • Set Global GitLab Variables (Set Node): Initializes critical global variables used throughout the flow, including GitLab project details and the backup tag name.

  • Fetch Workflows from n8n (n8n Node): Fetches the actual workflow data using the internal n8n API, filtered specifically by the backup-workflows tag.

  • Clean & Normalize Workflow Name (Code Node): A specialized n8n node that uses regex to find and standardize [customer: NAME] tags, which informs the folder structure in GitLab.

  • Prepare Workflow JSON for UI-Compatible Export (Code Node): Ensures the JSON output from n8n is stripped of internal execution data, resulting in a clean export that matches the format downloaded from the UI.

  • Prepare GitLab File Path (Code Node): Builds a unique and stable file path based on the workflow ID and the optional customer slug, preventing issues if the workflow name changes.

  • Fetch Existing File from GitLab (GitLab Node): Attempts to fetch the existing file. Crucially configured with 'On Error → Continue' to route new workflows (file not found) to the creation path.

  • Compare Workflow with GitLab Version (If Node): Performs a byte-by-byte comparison of the stringified JSON to decide if an update is necessary, reducing redundant Git commits.

  • Update/Create File in GitLab (GitLab Node): Executes the necessary write operations in GitLab, creating a new file or updating an existing one with detailed commit messages reflecting the name and path of the specific n8n workflow.

  • Summarize Backup Results (Code Node): The final n8n node which aggregates the results (created, updated, unchanged) for monitoring and final reporting.

Related n8n Workflows

Free

Nodes: 9 Nodes
Updated: December 26 2025
View all
Created by
Omar Kennouche | AI Nexus One
Omar Kennouche | AI Nexus One

Automation & AI consultant. I design practical n8n workflows connecting APIs, business tools and AI—focused on saving time, reducing errors and enabling growth.

Featured*