What this workflow does
This workflow compares live n8n workflows with JSON files in a GitLab repo.
It finds new, changed, or unchanged workflows.
The workflow creates or updates files in GitLab automatically.
This saves time, avoids mistakes, and keeps workflows in sync.
Tools and services used
- n8n: Hosts and runs automation workflows.
- GitLab: Stores JSON files of workflows in a repository.
- n8n GitLab node: Interacts with GitLab API for reading and writing files.
- Manual Trigger node: Starts the process manually on demand.
Inputs, processing steps, and output
Inputs
- All active workflows currently running in n8n.
- Repository information like owner, repo name, branch, and path from the Set node called Globals.
Processing
- Fetch each workflow live from n8n.
- Download corresponding workflow file from GitLab if exists.
- Extract GitLab JSON content from the binary file.
- Compare live workflow JSON and GitLab JSON ignoring fields like
updatedAtandglobal. - Classify workflows as new, same, diff, or error.
- Create new files in GitLab for new workflows.
- Update existing files in GitLab for diff workflows.
- Skip changes for same, and log errors for error.
Output
- GitLab repository updated with new and changed workflow JSON files.
- Status reports for all workflows processed.
Beginner step-by-step: How to use this workflow in n8n
Download and import the workflow
- Use the Download button on this page to get the workflow file.
- Open the n8n editor where workflows are managed.
- Choose “Import from File” and upload the downloaded workflow.
Configure the workflow
- Provide GitLab API credentials with read/write permission in the GitLab node.
- Update the Set node named Globals with your GitLab owner, repository name, branch, and path as strings.
- Check if any IDs, emails, or folder names in the workflow require your customization and update them.
- If the workflow includes the code from the Code node File status, nothing extra is needed since it uses expressions inside.
Test the workflow
- Click the Manual Trigger node to start the process.
- Watch the execution in the n8n UI to ensure no errors happen.
Activate for production
- When tests pass, toggle the workflow active switch in the top right corner of n8n.
- You can now run it manually or set schedules as you prefer.
For more control over your automation, consider self-host n8n.
Customization ideas
- Update Globals node to use any GitLab repo, branch, or folder.
- Add ignored fields in the Code node File status for newer JSON structure fields.
- Add notifications like Slack or Email after workflow runs using suitable nodes.
- Change batch size in SplitInBatches node Loop Over Workflows for faster or slower processing.
- Send error logs to external services using HTTP Request nodes.
Edge cases and error handling
- If GitLab files show “not found,” check branch, path, and case sensitivity in Globals.
- If the Code node throws JavaScript errors, check JSON formats and update comparison code.
- If API rate limits occur, reduce batch size or add delays between runs.
Summary
✓ This workflow finds new and changed n8n workflows by comparing with GitLab files.
✓ It updates GitLab files only when needed, saving time and mistakes.
✓ Using this saves manual work and keeps workflow versions clean and consistent.
→ User gets automatic syncing of n8n workflows with GitLab repository versions.
