diff --git a/deploy/n8n/Genome_ raw → commit.json b/deploy/n8n/Genome_ raw → commit.json new file mode 100644 index 0000000..d0dffe2 --- /dev/null +++ b/deploy/n8n/Genome_ raw → commit.json @@ -0,0 +1,222 @@ +{ + "name": "Genome: raw → commit", + "nodes": [ + { + "parameters": { + "rule": { + "interval": [ + { + "field": "cronExpression", + "expression": "*/2 * * * *" + } + ] + } + }, + "type": "n8n-nodes-base.scheduleTrigger", + "typeVersion": 1.3, + "position": [ + 384, + 1056 + ], + "id": "520c79c8-76e6-41c0-8836-4d8d8f4ed236", + "name": "Schedule: ogni 2 min" + }, + { + "parameters": { + "authentication": "privateKey", + "command": "sudo -u homelab -H /usr/local/bin/genome-raw-commit genome-test" + }, + "type": "n8n-nodes-base.ssh", + "typeVersion": 1, + "position": [ + 608, + 1056 + ], + "id": "fe89a85f-d63e-47d9-a7b4-08222f2635d0", + "name": "SSH: genome-raw-commit", + "executeOnce": true, + "credentials": { + "sshPrivateKey": { + "id": "GJQjKzte7Hjdfz89", + "name": "n8n container -> n8n-runner@nexus" + } + } + }, + { + "parameters": { + "jsCode": "// Lo script ora stampa JSON multilinea (jq -n). git manda i progressi su stderr,\n// quindi stdout e' SOLO il JSON: si parsa per intero.\nconst out = ($input.first().json.stdout || '').trim();\nlet data;\ntry {\n data = JSON.parse(out);\n} catch (e) {\n data = { status: 'error', reason: 'output non parsabile', genome: 'genome-test', raw: out };\n}\nreturn [{ json: data }];" + }, + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 832, + 1056 + ], + "id": "74051cc5-5760-453d-80e4-0696d31bfc15", + "name": "Parse result" + }, + { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "loose", + "version": 2 + }, + "conditions": [ + { + "id": "c0000000-0000-4000-8000-000000000001", + "leftValue": "={{ $json.status }}", + "rightValue": "noop", + "operator": { + "type": "string", + "operation": "notEquals" + } + } + ], + "combinator": "and" + }, + "options": {} + }, + "type": "n8n-nodes-base.if", + "typeVersion": 2.2, + "position": [ + 1056, + 1056 + ], + "id": "5813753d-f015-4a4e-b386-9d60659077c3", + "name": "IF: non noop" + }, + { + "parameters": { + "jsCode": "const d = $input.first().json;\nlet n;\nif (d.status === 'ok') {\n const f = d.files && d.files[0];\n n = {\n title: `Genome: ${d.commits} raw -> ${d.base}`,\n priority: 'default',\n tags: 'inbox_tray',\n body: `✅ ${d.genome}: ${d.commits} commit su ${d.base} (HEAD ${d.head})\\n\\n${d.summary || ''}`\n + (f ? `\\n\\n🔗 Forgejo: ${f.remote_url}\\n📂 Locale: ${f.local_url}` : '')\n };\n} else {\n n = {\n title: 'Genome raw commit: ERRORE',\n priority: 'high',\n tags: 'warning',\n body: `\\u274C ${d.genome || 'genome-test'}: ${d.reason || 'errore sconosciuto'}`\n };\n}\nreturn [{ json: n }];" + }, + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 1264, + 976 + ], + "id": "29eee748-4c2d-4e1e-8013-a64bc9cbf816", + "name": "Build ntfy" + }, + { + "parameters": { + "method": "POST", + "url": "http://ntfy/homelab-genome", + "authentication": "genericCredentialType", + "genericAuthType": "httpBearerAuth", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Title", + "value": "={{ $json.title }}" + }, + { + "name": "Priority", + "value": "={{ $json.priority }}" + }, + { + "name": "Tags", + "value": "={{ $json.tags }}" + } + ] + }, + "sendBody": true, + "contentType": "raw", + "rawContentType": "Raw / Text", + "body": "={{ $json.body }}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 1488, + 976 + ], + "id": "d9b6ca21-59ef-44cf-a4f7-a75dcc7eeab4", + "name": "ntfy: send notification", + "credentials": { + "httpHeaderAuth": { + "id": "TBPXSWOF63k9mvm8", + "name": "ntfy-token" + }, + "httpBearerAuth": { + "id": "nCv4CUN7Ef086Ewj", + "name": "Bearer Auth account" + } + } + } + ], + "pinData": {}, + "connections": { + "Schedule: ogni 2 min": { + "main": [ + [ + { + "node": "SSH: genome-raw-commit", + "type": "main", + "index": 0 + } + ] + ] + }, + "SSH: genome-raw-commit": { + "main": [ + [ + { + "node": "Parse result", + "type": "main", + "index": 0 + } + ] + ] + }, + "Parse result": { + "main": [ + [ + { + "node": "IF: non noop", + "type": "main", + "index": 0 + } + ] + ] + }, + "IF: non noop": { + "main": [ + [ + { + "node": "Build ntfy", + "type": "main", + "index": 0 + } + ] + ] + }, + "Build ntfy": { + "main": [ + [ + { + "node": "ntfy: send notification", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": true, + "settings": { + "executionOrder": "v1", + "binaryMode": "separate" + }, + "versionId": "9607be0b-cd8c-4e7a-9ddb-63b6ec22b65d", + "meta": { + "instanceId": "96b2f0ec76a4400bbd481c617b24b3b87024cc7a913efacccaf9fc85722e7417" + }, + "id": "whyxMpvJMYQ55J1M", + "tags": [] +} \ No newline at end of file