Sync staging n8n workflows to GitHub via pull request
Ready for 3.0Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.
Nodes used (10)
- GitHub
n8n-nodes-base.github - HTTP Request
n8n-nodes-base.httpRequest - Code
n8n-nodes-base.code - Extract from File
n8n-nodes-base.extractFromFile - Convert to File
n8n-nodes-base.convertToFile - Merge
n8n-nodes-base.merge - Edit Fields (Set)
n8n-nodes-base.set - If
n8n-nodes-base.if - Execute Workflow Trigger
n8n-nodes-base.executeWorkflowTrigger - n8n Trigger
n8n-nodes-base.n8nTrigger
What it does
Quick Overview This workflow takes a published workflow from a staging n8n instance, cleans noisy metadata, commits the JSON to a GitHub repository on a new branch, and opens a pull request against a base branch so workflow changes can be promoted via a standard GitHub review and merge process. How it works 1. Triggers when the workflow is activated or updated in n8n, or when another workflow calls it with a workflowid input. 2. Fetches the target workflow JSON from the staging n8n API using the provided workflow ID. 3. Removes workflow metadata fields (such as IDs and timestamps) to keep Git diffs focused on real changes, then converts the cleaned JSON into a formatted file payload. 4. Ensures the target GitHub repository exists, retrieves the base branch commit SHA, and creates a new branch named from the workflow name and version counter. 5. Checks whether a JSON file for the workflow already exists in the repository and then creates or updates that file on the new branch by committing the base64-encoded JSON. 6. Opens a GitHub pull request from the new branch into the configured base branch. Setup 1. Create a GitHub OAuth2 credential with access to the target repository (repo scope) and select it for the GitHub and GitHub API HTTP requests. 2. Create an n8n API credential for your staging instance and set stagingN8nBaseUrl to your staging n8n URL. 3. Update the publish variables to your repoOwner, repoName, baseBranch, and whether the repository should be private. 4. Ensure this workflow receives the correct workflow ID (via the workflowid input when executed by another workflow, or by adjusting the trigger/input mapping to your publish event source).