{
  "name": "Sync GitHub workflows to n8n after pull request merges",
  "nodes": [
    {
      "id": "4da3bb85-e6f9-406b-a7d5-fee1064da2a4",
      "name": "Define Local Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        200,
        -200
      ]
    },
    {
      "id": "4b36dfdb-6e69-4590-b47a-326198368a86",
      "name": "Github Trigger - When there is new pull request",
      "type": "n8n-nodes-base.githubTrigger",
      "position": [
        -20,
        -200
      ]
    },
    {
      "id": "74b7816b-48f2-4c1e-a636-fcbfb422a5e8",
      "name": "Check if trigger event is pull request merged",
      "type": "n8n-nodes-base.filter",
      "position": [
        420,
        -200
      ]
    },
    {
      "id": "f72522ad-d28d-42ed-95a5-45927c264596",
      "name": "Fetch merged commit details via GitHub API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        640,
        -200
      ]
    },
    {
      "id": "a97abd34-fd58-4b81-bacb-3cab9d58499b",
      "name": "Get files changes details",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        860,
        -200
      ]
    },
    {
      "id": "2aab8ec7-7bbf-4909-9175-d6ef503318ae",
      "name": "Filter modified workflows",
      "type": "n8n-nodes-base.filter",
      "position": [
        1080,
        -300
      ]
    },
    {
      "id": "5b14e46f-6bac-4e15-8a66-45fccc1ae624",
      "name": "Filter created workflows",
      "type": "n8n-nodes-base.filter",
      "position": [
        1080,
        -100
      ]
    },
    {
      "id": "e85cff90-626c-4673-8d94-0b5a8848d5be",
      "name": "Fetch workflow content from Git",
      "type": "n8n-nodes-base.github",
      "position": [
        1300,
        -100
      ]
    },
    {
      "id": "d0cc850d-3270-40f8-99ac-363ec8986487",
      "name": "Fetch workflow content from Git1",
      "type": "n8n-nodes-base.github",
      "position": [
        1300,
        -300
      ]
    },
    {
      "id": "157304a2-c198-4f8c-ac69-81f6adaad00b",
      "name": "Decode workflow content to json",
      "type": "n8n-nodes-base.set",
      "position": [
        1520,
        -300
      ]
    },
    {
      "id": "8dee2b87-85c7-42d0-b35f-fbe0107de733",
      "name": "Decode workflow content to json1",
      "type": "n8n-nodes-base.set",
      "position": [
        1520,
        -100
      ]
    },
    {
      "id": "2ffb439f-cacf-4af2-9f57-1f2ea94c5eae",
      "name": "Update workflow in n8n",
      "type": "n8n-nodes-base.n8n",
      "position": [
        1740,
        -300
      ]
    },
    {
      "id": "21bab1a6-5481-4728-a3fc-3749db3e4ca6",
      "name": "Create new workflow in n8n",
      "type": "n8n-nodes-base.n8n",
      "position": [
        1740,
        -100
      ]
    },
    {
      "id": "4092e6aa-183f-4f9e-ae77-8784e9817d5c",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -200,
        -580
      ],
      "parameters": {
        "width": 420,
        "height": 320,
        "content": "## Setup\n\n1. **Connect GitHub**: Use the `GitHub Trigger` node and configure GitHub API credentials.\nNote: I'd recommended to use *GitHub PAT (Personal Access Token) classic* with `repo` and `admin:re"
      }
    }
  ],
  "connections": {
    "Define Local Variables": {
      "main": [
        [
          {
            "node": "Check if trigger event is pull request merged",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter created workflows": {
      "main": [
        [
          {
            "node": "Fetch workflow content from Git",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter modified workflows": {
      "main": [
        [
          {
            "node": "Fetch workflow content from Git1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get files changes details": {
      "main": [
        [
          {
            "node": "Filter modified workflows",
            "type": "main",
            "index": 0
          },
          {
            "node": "Filter created workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Decode workflow content to json": {
      "main": [
        [
          {
            "node": "Update workflow in n8n",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch workflow content from Git": {
      "main": [
        [
          {
            "node": "Decode workflow content to json1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Decode workflow content to json1": {
      "main": [
        [
          {
            "node": "Create new workflow in n8n",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch workflow content from Git1": {
      "main": [
        [
          {
            "node": "Decode workflow content to json",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch merged commit details via GitHub API": {
      "main": [
        [
          {
            "node": "Get files changes details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if trigger event is pull request merged": {
      "main": [
        [
          {
            "node": "Fetch merged commit details via GitHub API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Github Trigger - When there is new pull request": {
      "main": [
        [
          {
            "node": "Define Local Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}