From ebbca679e47d4aed31ea56ddc197482bb8077253 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Mar 2026 12:57:24 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20address=20code=20review=20=E2=80=94=20im?= =?UTF-8?q?prove=20alert=20matching=20logic,=20fix=20email=20indentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> --- .github/workflows/server-patrol.yml | 26 ++++++++++++-------------- scripts/sync-patrol-to-notion.js | 9 ++++++--- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/server-patrol.yml b/.github/workflows/server-patrol.yml index 57588d0b..54954cc9 100644 --- a/.github/workflows/server-patrol.yml +++ b/.github/workflows/server-patrol.yml @@ -5,7 +5,7 @@ name: "🔍 Server Patrol · 服务器每日巡检" on: schedule: - - cron: '0 0,12 * * *' # UTC 00:00+12:00 = 北京 08:00+20:00 + - cron: '0 0,12 * * *' # UTC 00:00 and 12:00 = 北京 08:00 and 20:00 workflow_dispatch: workflow_run: workflows: ["🏠 Sandbox Deploy"] @@ -92,19 +92,17 @@ jobs: alerts = '\n'.join(f' ❌ {a}' for a in report['alerts']) fixed = '\n'.join(f' ✅ {f}' for f in report['auto_fixed']) - body = f"""🔍 铸渊服务器巡检报告 - 时间: {report['timestamp']} - - ⚠️ 发现 {report['alert_count']} 个异常: - {alerts} - - 🔧 自动修复 {report['fixed_count']} 个: - {fixed if fixed else ' (无)'} - - 磁盘使用率: {report['disk_usage_percent']}% - Nginx状态: {report['nginx_status']} - - —— 铸渊 · 光湖代码守护人格体""" + body = ( + f"🔍 铸渊服务器巡检报告\n" + f"时间: {report['timestamp']}\n\n" + f"⚠️ 发现 {report['alert_count']} 个异常:\n" + f"{alerts}\n\n" + f"🔧 自动修复 {report['fixed_count']} 个:\n" + f"{fixed if fixed else ' (无)'}\n\n" + f"磁盘使用率: {report['disk_usage_percent']}%\n" + f"Nginx状态: {report['nginx_status']}\n\n" + f"—— 铸渊 · 光湖代码守护人格体" + ) smtp_user = os.environ['SMTP_USER'] smtp_pass = os.environ['SMTP_PASS'] diff --git a/scripts/sync-patrol-to-notion.js b/scripts/sync-patrol-to-notion.js index 12ebccfa..78ca99e8 100644 --- a/scripts/sync-patrol-to-notion.js +++ b/scripts/sync-patrol-to-notion.js @@ -120,10 +120,13 @@ async function main() { } // 找出未能自动修复的异常 → 开工单 - const autoFixedSet = new Set(report.auto_fixed || []); + const autoFixed = report.auto_fixed || []; const unresolvedAlerts = (report.alerts || []).filter(alert => { - // 如果 alert 对应有一条 auto_fixed,说明已修复,不开工单 - return !report.auto_fixed.some(fix => fix.includes(alert.split(' ')[0])); + // 检查是否有对应的自动修复记录(修复消息中包含完整的异常描述关键词) + return !autoFixed.some(fix => { + const alertKey = alert.replace(/[::].*/g, '').trim(); + return fix.includes(alertKey); + }); }); if (unresolvedAlerts.length === 0) {