{
  "name": "Automate GitLab merge requests using APIs with n8n",
  "nodes": [
    {
      "id": "b9a807c3-5847-477a-a242-2fdf5b15ba7e",
      "name": "API to Check existing merge request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -840,
        -20
      ]
    },
    {
      "id": "42270a5a-d696-44f3-b2f5-16b2ddb3488c",
      "name": "Is Exists",
      "type": "n8n-nodes-base.if",
      "position": [
        -660,
        -20
      ]
    },
    {
      "id": "d380c943-0525-4976-9e70-c90de1177f0c",
      "name": "Create New Merge Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -440,
        -200
      ]
    },
    {
      "id": "600a0ed5-cb68-4479-8aee-55b55f0d8630",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -440,
        160
      ]
    },
    {
      "id": "555643cb-761c-41ec-b983-8e0194851a8d",
      "name": "API to CLOSE existing Merge Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -220,
        180
      ]
    },
    {
      "id": "0c94b06a-80e3-4e50-8bac-2bd4015f085e",
      "name": "Add Custom Notes To Merge Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -220,
        -200
      ]
    },
    {
      "id": "8e849f4f-2a52-46ba-9e0a-17126a8d966c",
      "name": "30 secs wait to approve merge request and pipeline to finish1",
      "type": "n8n-nodes-base.wait",
      "position": [
        140,
        -200
      ]
    },
    {
      "id": "05cca829-b2df-4c1e-9441-56349acc4a0d",
      "name": "Merge When Pipeline Succeeds",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        720,
        -200
      ]
    },
    {
      "id": "e3ce9cdc-5484-4b4b-8701-6b9089a1f76d",
      "name": "setValueForMerge",
      "type": "n8n-nodes-base.set",
      "position": [
        460,
        -200
      ]
    },
    {
      "id": "0d49ec98-4806-492e-a6c2-a298ed8bb11a",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1160,
        -20
      ]
    }
  ],
  "connections": {
    "Is Exists": {
      "main": [
        [
          {
            "node": "Create New Merge Request",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "API to Check existing merge request",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "API to CLOSE existing Merge Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "API to Check existing merge request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "setValueForMerge": {
      "main": [
        [
          {
            "node": "Merge When Pipeline Succeeds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create New Merge Request": {
      "main": [
        [
          {
            "node": "Add Custom Notes To Merge Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Custom Notes To Merge Request": {
      "main": [
        [
          {
            "node": "30 secs wait to approve merge request and pipeline to finish1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "API to CLOSE existing Merge Request": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "API to Check existing merge request": {
      "main": [
        [
          {
            "node": "Is Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "30 secs wait to approve merge request and pipeline to finish1": {
      "main": [
        [
          {
            "node": "setValueForMerge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}