Automate GitLab Merge Requests Using APIs with n8n
# **Who is this template for?** This template is designed for developers, DevOps engineers, and automation enthusiasts who want to streamline their GitLab merge request process using n8n, a low-code workflow automation tool. It eliminates manual intervention by automating the merging of GitLab branches through API calls. # **How it works?** - **Trigger the workflow**: The workflow can be triggered by a webhook, a scheduled event, or a GitLab event (e.g., a new merge request is created or approved). - **Fetch Merge Request Details**: n8n makes an API call to GitLab to retrieve merge request details. - **Check Merge Conditions**: The workflow validates whether the merge request meets predefined conditions (e.g., approvals met, CI/CD pipelines passed). - **Perform the Merge**: If all conditions are met, n8n sends a request to the GitLab API to merge the branch automatically. # **Setup Steps** **1. Prerequisites** - An n8n instance (Self-hosted or Cloud) - A GitLab personal access token with API access - A GitLab repository with merge requests enabled **2. Create the n8n Workflow** - Set up a trigger: Choose a trigger node (Webhook, Cron, or GitLab Trigger). - Fetch merge request details: Add an HTTP Request node to call GET /merge_requests/:id from GitLab API. - Validate conditions: - Check if the merge request has necessary approvals. - Ensure CI/CD pipelines have passed. - Merge the request: - Use an HTTP Request node to call PUT /merge_requests/:id/merge API. **3. Test the Workflow** - Create a test merge request. - Check if the workflow triggers and merges automatically. - Debug using n8n logs if needed. **4. Deploy and Monitor** - Deploy the workflow in production. - Use n8n's monitoring features to track execution. This template enables seamless GitLab merge automation, improving efficiency and reducing manual work! #### Note: Never hard code API token or secret in your HTTP request.
- Platform
- n8n
- Category
- Development & IT
- Price
- $9.99
- Creator
- Aditya Gaur
- if
- set
- wait
- httpRequest
- splitInBatches
- scheduleTrigger
How to import this workflow into n8n
- 1Purchase or download the workflow to get the n8n workflow JSON file.
- 2In your n8n instance, open Workflows and choose "Import from File" (or paste the JSON with Ctrl+V on the canvas).
- 3Open each node marked with a credential warning and connect your own accounts and API keys.
- 4Run the workflow once manually to verify the data flow, then toggle it to Active.
Related Development & IT workflows
- Create daily historical AI videos with Gemini, fal.ai, Telegram and YouTube$14.99
- Advanced multi-agent AI personal assistant with 250+ task capabilities (WhatsApp + GPT)$2.99
- Send Organized Security CVE Digests from NVD with AI-Polished Summaries to Gmail$4.99
- Learn n8n basics in 3 easy steps ✨$14.99
- Automated multi-platform sales agent with RAG, CRM & payment processing$2.99
- Version Control n8n Workflows in GitLab with Custom and Organization$14.99
More from Aditya Gaur
Need this deployed? We'll set it up for you.
Our automation experts deploy this workflow in your stack, connect your accounts, and verify it works — or build a custom solution from scratch.