Files
buryan-infra/infra/n8n/workflows/workflow-current.json
T

231 lines
6.9 KiB
JSON

[
{
"id": "TSqu00NJx2JOrtoN",
"name": "Uptime Kuma → Gitea Self-Healing",
"active": false,
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "uptime-kuma",
"responseMode": "responseNode",
"options": {}
},
"name": "Uptime Kuma Webhook",
"webhookId": "95de5809-c2a6-4ba1-a472-89debbc46fbb",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
144,
256
],
"id": "a4c37fdc-fe82-4d53-8cd9-0d6af7afc90f"
},
{
"parameters": {
"jsCode": "const webhookData = $input.first().json;\nconst body = webhookData.body || webhookData;\n\n// УМНАЯ ПРОВЕРКА: если monitor_name пуст или 'Unknown', берем домен из URL\nlet monitorName = body.monitor_name || 'Unknown';\nif (monitorName === 'Unknown' || !monitorName) {\n const url = body.monitor_url || '';\n monitorName = url ? url.replace(/https?:\\/\\//, '').split('/')[0] : 'Unknown Service';\n}\n\nconst monitorUrl = body.monitor_url || 'N/A';\nconst status = parseInt(body.heartbeat_status) || 0;\nconst message = body.heartbeat_message || 'Service is down';\n\nconst ctMatch = monitorName.match(/\\((\\d+)\\)/);\nconst ctId = ctMatch ? ctMatch[1] : null;\n\n// Создаем четкий заголовок для Gitea\nconst giteaTitle = `AUTO-FIX: ${monitorName} DOWN`;\n\nreturn [{\n json: {\n monitorName,\n monitorUrl,\n status,\n message,\n ctId,\n giteaTitle,\n timestamp: new Date().toISOString(),\n shouldAlert: status === 0 && ctId !== null\n }\n}];"
},
"name": "Extract Info",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
368,
256
],
"id": "23e46b7d-28db-4d26-b90b-f86f49d216bc"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "b1e6f2a0-1111-4222-8333-444455556666",
"leftValue": "={{ $json.shouldAlert }}",
"rightValue": true,
"operator": {
"type": "boolean",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"name": "Should Create Issue?",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
608,
256
],
"id": "2b7f557f-8d80-4266-8f67-6b1dc3c38f25"
},
{
"parameters": {
"method": "POST",
"url": "http://192.168.1.140:3000/api/v1/repos/agent-qwen/buryan-infra/issues",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "token {{GITEA_TOKEN}}"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ JSON.stringify({ title: $json.giteaTitle, body: \"CT_DOWN: \" + $json.ctId + \"\\n\\nАвтоматическое восстановление: \" + $json.monitorName + \".\\n\\nURL: \" + $json.monitorUrl + \"\\nMessage: \" + $json.message + \"\\nTime: \" + $json.timestamp, labels: [2] }) }}",
"options": {}
},
"name": "Create Gitea Issue",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
832,
160
],
"id": "40bcfe34-b905-4ab2-ac2d-5de5ad5e9d5b"
},
{
"parameters": {
"method": "POST",
"url": "https://193.233.210.184/tg-api/bot8668603602:AAHVmUmq44dcomw8QOfw_qj1aICXuT5c5XU/sendMessage",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "chat_id",
"value": "=273442500"
},
{
"name": "text",
"value": "=🚨 <b>{{ $json.monitorName }}</b> DOWN\n\nURL: {{ $json.monitorUrl }}\nВремя: {{ new Date().toLocaleString(\"ru-RU\") }}\n\n✅ Issue создан в Gitea: {{ $json.giteaTitle }}"
},
{
"name": "parse_mode",
"value": "HTML"
}
]
},
"options": {
"allowUnauthorizedCerts": true
}
},
"name": "Notify Telegram",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
1088,
256
],
"id": "9cbd83b9-944f-4d3f-9803-62ccf51cd458"
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ JSON.stringify({ ok: true, issue_created: $json.html_url || null }) }}",
"options": {}
},
"name": "Respond",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
1312,
256
],
"id": "6eac3128-5c63-4315-89af-4fb0be610522"
}
],
"connections": {
"Uptime Kuma Webhook": {
"main": [
[
{
"node": "Extract Info",
"type": "main",
"index": 0
}
]
]
},
"Extract Info": {
"main": [
[
{
"node": "Should Create Issue?",
"type": "main",
"index": 0
}
]
]
},
"Should Create Issue?": {
"main": [
[
{
"node": "Create Gitea Issue",
"type": "main",
"index": 0
}
],
[
{
"node": "Respond",
"type": "main",
"index": 0
}
]
]
},
"Create Gitea Issue": {
"main": [
[
{
"node": "Notify Telegram",
"type": "main",
"index": 0
}
]
]
},
"Notify Telegram": {
"main": [
[
{
"node": "Respond",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"binaryMode": "separate",
"executionOrder": "v1"
},
"staticData": null
}
]