2023-01-24 18:26:19 +00:00
|
|
|
{
|
|
|
|
"active": true,
|
|
|
|
"connections": {
|
|
|
|
"n8n": {
|
|
|
|
"main": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "OneAtATime",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"new": {
|
|
|
|
"main": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "GitHub Create",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"same": {
|
|
|
|
"main": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "OneAtATime",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"Merge": {
|
|
|
|
"main": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "isDiffOrNew",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"GitHub": {
|
|
|
|
"main": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "Merge",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"Globals": {
|
|
|
|
"main": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "n8n",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"different": {
|
|
|
|
"main": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "GitHub Edit",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"OneAtATime": {
|
|
|
|
"main": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "GitHub",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"node": "Merge",
|
|
|
|
"type": "main",
|
|
|
|
"index": 1
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"GitHub Edit": {
|
|
|
|
"main": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "OneAtATime",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"isDiffOrNew": {
|
|
|
|
"main": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "github_status",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"GitHub Create": {
|
|
|
|
"main": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "OneAtATime",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"github_status": {
|
|
|
|
"main": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "same",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "different",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "new",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"Every 12 hours": {
|
|
|
|
"main": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "Globals",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"On clicking 'execute'": {
|
|
|
|
"main": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"node": "Globals",
|
|
|
|
"type": "main",
|
|
|
|
"index": 0
|
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"createdAt": "2023-01-18T18:02:58.052Z",
|
2023-03-30 16:00:36 +00:00
|
|
|
"id": "4",
|
2023-01-24 18:26:19 +00:00
|
|
|
"name": "n8n Backup -> Github",
|
|
|
|
"nodes": [
|
|
|
|
{
|
|
|
|
"parameters": {},
|
|
|
|
"id": "3e4457c2-0319-42ae-ace8-a76acaf4de6a",
|
|
|
|
"name": "On clicking 'execute'",
|
|
|
|
"type": "n8n-nodes-base.manualTrigger",
|
|
|
|
"position": [
|
|
|
|
-2725,
|
|
|
|
1355
|
|
|
|
],
|
|
|
|
"typeVersion": 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"parameters": {
|
|
|
|
"authentication": "oAuth2",
|
|
|
|
"resource": "file",
|
|
|
|
"operation": "get",
|
|
|
|
"owner": "={{$node[\"Globals\"].json[\"repo\"][\"owner\"]}}",
|
|
|
|
"repository": "={{$node[\"Globals\"].json[\"repo\"][\"name\"]}}",
|
|
|
|
"filePath": "={{$node[\"Globals\"].json[\"repo\"][\"path\"]}}{{$json[\"name\"]}}.json",
|
|
|
|
"asBinaryProperty": false,
|
|
|
|
"additionalParameters": {}
|
|
|
|
},
|
|
|
|
"id": "cbc3c4e4-da54-4d9a-81e0-8d9c2ada9e2b",
|
|
|
|
"name": "GitHub",
|
|
|
|
"type": "n8n-nodes-base.github",
|
|
|
|
"position": [
|
|
|
|
-1880,
|
|
|
|
1320
|
|
|
|
],
|
|
|
|
"typeVersion": 1,
|
|
|
|
"alwaysOutputData": true,
|
|
|
|
"credentials": {
|
|
|
|
"githubOAuth2Api": {
|
|
|
|
"id": "5",
|
|
|
|
"name": "GitHub account"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"continueOnFail": true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"parameters": {
|
|
|
|
"dataType": "string",
|
|
|
|
"value1": "={{$json[\"github_status\"]}}",
|
|
|
|
"rules": {
|
|
|
|
"rules": [
|
|
|
|
{
|
|
|
|
"value2": "same"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"value2": "different",
|
|
|
|
"output": 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"value2": "new",
|
|
|
|
"output": 2
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"id": "017dbf52-166b-4325-a037-a96d1a5c3338",
|
|
|
|
"name": "github_status",
|
|
|
|
"type": "n8n-nodes-base.switch",
|
|
|
|
"position": [
|
|
|
|
-1240,
|
|
|
|
1460
|
|
|
|
],
|
|
|
|
"typeVersion": 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"parameters": {},
|
|
|
|
"id": "b9740032-5731-4395-8a21-2b7b403143c5",
|
|
|
|
"name": "same",
|
|
|
|
"type": "n8n-nodes-base.noOp",
|
|
|
|
"position": [
|
|
|
|
-1000,
|
|
|
|
1260
|
|
|
|
],
|
|
|
|
"typeVersion": 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"parameters": {},
|
|
|
|
"id": "9957a10d-9ee9-4f8e-a486-47f7770b3801",
|
|
|
|
"name": "different",
|
|
|
|
"type": "n8n-nodes-base.noOp",
|
|
|
|
"position": [
|
|
|
|
-1000,
|
|
|
|
1460
|
|
|
|
],
|
|
|
|
"typeVersion": 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"parameters": {},
|
|
|
|
"id": "01a91984-5575-462d-9931-6646ea62a230",
|
|
|
|
"name": "new",
|
|
|
|
"type": "n8n-nodes-base.noOp",
|
|
|
|
"position": [
|
|
|
|
-1000,
|
|
|
|
1640
|
|
|
|
],
|
|
|
|
"typeVersion": 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"parameters": {
|
|
|
|
"authentication": "oAuth2",
|
|
|
|
"resource": "file",
|
|
|
|
"operation": "edit",
|
|
|
|
"owner": "={{$node[\"Globals\"].json[\"repo\"][\"owner\"]}}",
|
|
|
|
"repository": "={{$node[\"Globals\"].json[\"repo\"][\"name\"]}}",
|
|
|
|
"filePath": "={{$node[\"Globals\"].json[\"repo\"][\"path\"]}}{{$node[\"OneAtATime\"].json[\"name\"]}}.json",
|
|
|
|
"fileContent": "={{$node[\"isDiffOrNew\"].json[\"n8n_data_stringy\"]}}",
|
|
|
|
"commitMessage": "=[N8N Backup] {{$node[\"OneAtATime\"].json[\"name\"]}}.json ({{$json[\"github_status\"]}})"
|
|
|
|
},
|
|
|
|
"id": "42f0f34b-cc15-448f-9d9a-8671fad4cf58",
|
|
|
|
"name": "GitHub Edit",
|
|
|
|
"type": "n8n-nodes-base.github",
|
|
|
|
"position": [
|
|
|
|
-820,
|
|
|
|
1460
|
|
|
|
],
|
|
|
|
"typeVersion": 1,
|
|
|
|
"credentials": {
|
|
|
|
"githubOAuth2Api": {
|
|
|
|
"id": "5",
|
|
|
|
"name": "GitHub account"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"parameters": {
|
|
|
|
"authentication": "oAuth2",
|
|
|
|
"resource": "file",
|
|
|
|
"owner": "={{$node[\"Globals\"].json[\"repo\"][\"owner\"]}}",
|
|
|
|
"repository": "={{$node[\"Globals\"].json[\"repo\"][\"name\"]}}",
|
|
|
|
"filePath": "={{$node[\"Globals\"].json[\"repo\"][\"path\"]}}{{$node[\"OneAtATime\"].json[\"name\"]}}.json",
|
|
|
|
"fileContent": "={{$node[\"isDiffOrNew\"].json[\"n8n_data_stringy\"]}}",
|
|
|
|
"commitMessage": "=[N8N Backup] {{$node[\"OneAtATime\"].json[\"name\"]}}.json ({{$json[\"github_status\"]}})"
|
|
|
|
},
|
|
|
|
"id": "f5b9e301-4c64-42ed-9433-14a7b54bcec4",
|
|
|
|
"name": "GitHub Create",
|
|
|
|
"type": "n8n-nodes-base.github",
|
|
|
|
"position": [
|
|
|
|
-820,
|
|
|
|
1640
|
|
|
|
],
|
|
|
|
"typeVersion": 1,
|
|
|
|
"credentials": {
|
|
|
|
"githubOAuth2Api": {
|
|
|
|
"id": "5",
|
|
|
|
"name": "GitHub account"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"parameters": {
|
|
|
|
"batchSize": 1,
|
|
|
|
"options": {}
|
|
|
|
},
|
|
|
|
"id": "cc6e0d03-49c5-43ae-b000-66172ff83c42",
|
|
|
|
"name": "OneAtATime",
|
|
|
|
"type": "n8n-nodes-base.splitInBatches",
|
|
|
|
"position": [
|
|
|
|
-2100,
|
|
|
|
1480
|
|
|
|
],
|
|
|
|
"typeVersion": 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"parameters": {
|
|
|
|
"values": {
|
|
|
|
"string": [
|
|
|
|
{
|
|
|
|
"name": "repo.owner",
|
|
|
|
"value": "m3tam3re"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "repo.name",
|
|
|
|
"value": "n8n-backup"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "repo.path",
|
|
|
|
"value": "workflows/"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"options": {}
|
|
|
|
},
|
|
|
|
"id": "d5c2012c-3975-4b8a-8ff3-4d3ebd071793",
|
|
|
|
"name": "Globals",
|
|
|
|
"type": "n8n-nodes-base.set",
|
|
|
|
"position": [
|
|
|
|
-2540,
|
|
|
|
1480
|
|
|
|
],
|
|
|
|
"typeVersion": 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"parameters": {
|
|
|
|
"triggerTimes": {
|
|
|
|
"item": [
|
|
|
|
{
|
|
|
|
"mode": "everyX",
|
|
|
|
"value": 12
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"id": "4f3b0a2d-efcb-46f3-9717-fb9f6c4c090e",
|
|
|
|
"name": "Every 12 hours",
|
|
|
|
"type": "n8n-nodes-base.cron",
|
|
|
|
"position": [
|
|
|
|
-2725,
|
|
|
|
1615
|
|
|
|
],
|
|
|
|
"typeVersion": 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"parameters": {
|
|
|
|
"filters": {}
|
|
|
|
},
|
|
|
|
"id": "fbd0a05a-dfeb-4ea8-8808-95e4cad65293",
|
|
|
|
"name": "n8n",
|
|
|
|
"type": "n8n-nodes-base.n8n",
|
|
|
|
"position": [
|
|
|
|
-2340,
|
|
|
|
1480
|
|
|
|
],
|
|
|
|
"typeVersion": 1,
|
|
|
|
"credentials": {
|
|
|
|
"n8nApi": {
|
|
|
|
"id": "7",
|
|
|
|
"name": "n8n account"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"parameters": {
|
|
|
|
"jsCode": "// File Returned with Content\nif (Object.keys($input.all()[0].json).includes(\"content\")) {\n // Get JSON Objects\n var origWorkflow = JSON.parse(Buffer.from($input.all()[0].json.content, 'base64'));\n var n8nWorkflow = $input.all()[1].json;\n \n // Order JSON Objects\n var orderedOriginal = {}\n var orderedActual = {}\n \n Object.keys(origWorkflow).sort().forEach(function(key) {\n orderedOriginal[key] = origWorkflow[key];\n });\n \n Object.keys(n8nWorkflow).sort().forEach(function(key) {\n orderedActual[key] = n8nWorkflow[key];\n });\n\n // Determine Difference\n if ( JSON.stringify(orderedOriginal) === JSON.stringify(orderedActual) ) {\n $input.all()[0].json.github_status = \"same\";\n $input.all()[0].json.content_decoded = orderedOriginal;\n } else {\n $input.all()[0].json.github_status = \"different\";\n $input.all()[0].json.content_decoded = orderedOriginal;\n $input.all()[0].json.n8n_data_stringy = JSON.stringify(orderedActual, null, 2);\n }\n// No File Returned / New Workflow\n} else {\n // Order JSON Object\n var n8nWorkflow = ($input.all()[1].json);\n var orderedActual = {}\n Object.keys(n8nWorkflow).sort().forEach(function(key) {\n orderedActual[key] = n8nWorkflow[key];\n });\n \n // Proper Formatting\n $input.all()[0].json.github_status = \"new\";\n $input.all()[0].json.n8n_data_stringy = JSON.stringify(orderedActual, null, 2);\n}\n\n// Return Items\nreturn $input.all();"
|
|
|
|
},
|
|
|
|
"id": "750612d8-b83a-4fc9-a19f-7d7882f1eaf0",
|
|
|
|
"name": "isDiffOrNew",
|
|
|
|
"type": "n8n-nodes-base.code",
|
|
|
|
"position": [
|
|
|
|
-1480,
|
|
|
|
1460
|
|
|
|
],
|
|
|
|
"typeVersion": 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"parameters": {},
|
|
|
|
"id": "fa8a7e36-4cad-4174-b765-aa45086e3f73",
|
|
|
|
"name": "Merge",
|
|
|
|
"type": "n8n-nodes-base.merge",
|
|
|
|
"position": [
|
|
|
|
-1660,
|
|
|
|
1460
|
|
|
|
],
|
|
|
|
"typeVersion": 2
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"pinData": {},
|
|
|
|
"settings": {},
|
|
|
|
"staticData": null,
|
|
|
|
"tags": [],
|
2023-03-30 16:00:36 +00:00
|
|
|
"triggerCount": 1,
|
|
|
|
"updatedAt": "2023-01-18T18:03:58.967Z",
|
|
|
|
"versionId": "9e27c301-0d8b-4d5c-a45c-a00fbbc4c71c"
|
2023-01-24 18:26:19 +00:00
|
|
|
}
|