{ "id": "0WxkD9-eMPQr7WJy6LiDV", "name": "git-sync-workflow", "updatedAt": "2026-01-19T15:18:45.786Z", "active": true, "nodes": [ { "parameters": { "filters": {}, "requestOptions": {} }, "type": "n8n-nodes-base.n8n", "typeVersion": 1, "position": [ -1312, 240 ], "id": "daa532fa-55b4-4a63-9b0a-c15bcc68e3fe", "name": "Get All Workflows", "credentials": { "n8nApi": { "id": "6fnLt2dVUQGp0JYd", "name": "n8n account" } } }, { "parameters": { "url": "=https://api.github.com/repos/oharu121/n8n-workflow/contents/workflows/{{ $json.filename }}", "authentication": "genericCredentialType", "genericAuthType": "httpBearerAuth", "sendQuery": true, "queryParameters": { "parameters": [ { "name": "ref", "value": "main" } ] }, "options": { "response": { "response": { "neverError": true, "responseFormat": "json" } } } }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ -208, 144 ], "id": "4e6dabc2-f6f2-4141-b0ae-6be37bc342da", "name": "Get File SHA", "credentials": { "httpBearerAuth": { "id": "6JPGyoToOxOcHftx", "name": "n8n sync github token" } } }, { "parameters": { "method": "PUT", "url": "=https://api.github.com/repos/oharu121/n8n-workflow/contents/workflows/{{ $json.filename }}\n", "authentication": "genericCredentialType", "genericAuthType": "httpBearerAuth", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ $json.requestBody }}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 240, 144 ], "id": "cd6044ea-f6eb-4533-9ac8-e2df8feae10d", "name": "Create/Update File", "credentials": { "httpBearerAuth": { "id": "6JPGyoToOxOcHftx", "name": "n8n sync github token" } } }, { "parameters": {}, "type": "n8n-nodes-base.noOp", "typeVersion": 1, "position": [ -208, 336 ], "id": "80a3d37f-da98-4828-bc64-aac6074aa490", "name": "No Changes" }, { "parameters": { "rule": { "interval": [ {} ] } }, "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.2, "position": [ -1536, 240 ], "id": "6181b14b-80e7-48d6-85e8-60d1eed86d35", "name": "Schedule Trigger" }, { "parameters": { "mode": "runOnceForEachItem", "jsCode": "const workflow = $('Compare Dates').item.json;\nconst sha = $json.sha || null;\n\nconst content = JSON.stringify(workflow, null, 2) + '\\n';\nconst contentBase64 = Buffer.from(content).toString('base64');\n\nconst body = {\n message: `chore(n8n): sync workflow '${workflow.name}' [auto-sync]`,\n content: contentBase64,\n branch: 'main'\n};\n\nif (sha) {\n body.sha = sha;\n}\n\nreturn { \n json: { \n requestBody: body, \n filename: workflow.filename \n } \n};\n" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 16, 144 ], "id": "be4eaaf3-5c16-4f8b-847d-322685081b5e", "name": "Build Request Body" }, { "parameters": { "url": "https://api.github.com/repos/oharu121/n8n-workflow/commits", "authentication": "genericCredentialType", "genericAuthType": "httpBearerAuth", "sendQuery": true, "queryParameters": { "parameters": [ { "name": "path", "value": "=workflows/{{ $json.name }}.json" }, { "name": "per_page", "value": "1" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.3, "position": [ -880, 240 ], "id": "ecf243ba-d6a0-4c72-a8e4-44ba232b11fe", "name": "Get GitHub Commits", "credentials": { "httpBearerAuth": { "id": "6JPGyoToOxOcHftx", "name": "n8n sync github token" } } }, { "parameters": { "jsCode": "const workflows = $('Slim Workflows').all();\nconst commits = $('Get GitHub Commits').all();\n\nconst results = [];\nfor (let i = 0; i < workflows.length; i++) {\n const wf = workflows[i].json;\n const commit = commits[i].json;\n \n const n8nUpdatedAt = new Date(wf.updatedAt);\n const githubCommitDate = new Date(commit.commit.committer.date);\n \n const needsSync = n8nUpdatedAt > githubCommitDate;\n \n results.push({\n json: {\n ...wf,\n filename: wf.name + '.json',\n needsSync,\n reason: needsSync ? 'updated' : 'already synced'\n }\n });\n}\n\nreturn results;" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ -656, 240 ], "id": "21c15c6f-2a70-49b8-8e4c-0cd3ba404492", "name": "Compare Dates" }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 }, "conditions": [ { "id": "has-changes-condition", "leftValue": "={{ $json.needsSync }}", "rightValue": true, "operator": { "type": "boolean", "operation": "equals" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.2, "position": [ -432, 240 ], "id": "8d02eba5-2aa2-44ac-b28f-622f7169de8c", "name": "Need Sync?" }, { "parameters": { "jsCode": "const workflows = $input.all();\n\nreturn workflows.map(item => {\n const wf = item.json;\n \n // Keep only essential fields for sync\n return {\n json: {\n id: wf.id,\n name: wf.name,\n updatedAt: wf.updatedAt,\n active: wf.active,\n nodes: wf.nodes,\n connections: wf.connections,\n settings: wf.settings,\n staticData: wf.staticData || null,\n meta: wf.meta,\n pinData: wf.pinData || {}\n }\n };\n});\n" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ -1104, 240 ], "id": "7373959d-cf1c-4fe4-8fd9-14e9ea6e82c3", "name": "Slim Workflows" } ], "connections": { "Get All Workflows": { "main": [ [ { "node": "Slim Workflows", "type": "main", "index": 0 } ] ] }, "Get File SHA": { "main": [ [ { "node": "Build Request Body", "type": "main", "index": 0 } ] ] }, "Create/Update File": { "main": [ [] ] }, "Schedule Trigger": { "main": [ [ { "node": "Get All Workflows", "type": "main", "index": 0 } ] ] }, "Build Request Body": { "main": [ [ { "node": "Create/Update File", "type": "main", "index": 0 } ] ] }, "Get GitHub Commits": { "main": [ [ { "node": "Compare Dates", "type": "main", "index": 0 } ] ] }, "Compare Dates": { "main": [ [ { "node": "Need Sync?", "type": "main", "index": 0 } ] ] }, "Need Sync?": { "main": [ [ { "node": "Get File SHA", "type": "main", "index": 0 } ], [ { "node": "No Changes", "type": "main", "index": 0 } ] ] }, "Slim Workflows": { "main": [ [ { "node": "Get GitHub Commits", "type": "main", "index": 0 } ] ] } }, "settings": { "executionOrder": "v1", "availableInMCP": false }, "staticData": null, "meta": { "templateCredsSetupCompleted": true }, "pinData": {}, "filename": "git-sync-workflow.json", "needsSync": true, "reason": "updated" }