Files
ewoooc/n8n-workflows/19-gcp-uat-data-sync.json
ogt 1b4f3a7bbe
Some checks failed
CD Pipeline / deploy (push) Failing after 59s
feat: EwoooC 初始化 — 完整專案推版至 Gitea
- 建立 Gitea Actions CD pipeline (.gitea/workflows/cd.yaml)
- 部署模式: rsync Python 檔案至 188 → docker restart (volume mount)
- Dockerfile/requirements 變動時自動重建 Docker image
- 部署通知: Telegram (開始/成功/失敗)
- 健康檢查: https://mo.wooo.work/health (最多 5 次重試)
- 同步最新 CLAUDE.md / ADR-008 / memory (2026-04-19)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 01:21:13 +08:00

84 lines
2.9 KiB
JSON

{
"name": "GCP → UAT 資料同步",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"field": "cronExpression",
"expression": "0 2 * * *"
}
]
}
},
"id": "schedule",
"name": "每日 02:00 執行",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [240, 300]
},
{
"parameters": {
"command": "/home/wooo/momo_pro_system/scripts/sync_gcp_to_uat.sh 2>&1",
"cwd": "/home/wooo/momo_pro_system"
},
"id": "execute-sync",
"name": "執行同步腳本",
"type": "n8n-nodes-base.executeCommand",
"typeVersion": 1,
"position": [460, 300],
"continueOnFail": true
},
{
"parameters": {
"jsCode": "const output = $input.first().json.stdout || '';\nconst stderr = $input.first().json.stderr || '';\nconst exitCode = $input.first().json.exitCode;\n\nconst now = new Date().toLocaleString('zh-TW', { timeZone: 'Asia/Taipei' });\n\nlet success = exitCode === 0;\nlet message = '';\n\nif (success) {\n // 從輸出中提取統計資訊\n const statsMatch = output.match(/UAT 資料表統計:[\\s\\S]*?同步完成/);\n const stats = statsMatch ? statsMatch[0] : '';\n \n message = `✅ <b>GCP → UAT 資料同步完成</b>\\n\\n`;\n message += `📊 同步成功\\n`;\n message += `⏰ 時間: ${now}`;\n} else {\n message = `🔴 <b>GCP → UAT 資料同步失敗</b>\\n\\n`;\n message += `❌ 錯誤: ${stderr || output.slice(-500)}\\n`;\n message += `⏰ 時間: ${now}`;\n}\n\nreturn [{\n json: {\n success,\n message,\n exitCode,\n output: output.slice(-1000),\n timestamp: now\n }\n}];"
},
"id": "process-result",
"name": "處理結果",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [680, 300]
},
{
"parameters": {
"url": "https://api.telegram.org/bot8075645931:AAH-EGKMo8ZC4QJs-Nc1_0s92xHrGdQvdpg/sendMessage",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"chat_id\": \"5619078117\",\n \"parse_mode\": \"HTML\",\n \"text\": \"{{ $json.message }}\"\n}",
"options": {}
},
"id": "telegram",
"name": "Telegram 通知",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [900, 300]
}
],
"connections": {
"每日 02:00 執行": {
"main": [
[{ "node": "執行同步腳本", "type": "main", "index": 0 }]
]
},
"執行同步腳本": {
"main": [
[{ "node": "處理結果", "type": "main", "index": 0 }]
]
},
"處理結果": {
"main": [
[{ "node": "Telegram 通知", "type": "main", "index": 0 }]
]
}
},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"tags": [],
"triggerCount": 0,
"updatedAt": "2026-02-07T15:30:00.000Z",
"versionId": "1"
}