Guanghu Domestic Migration d1e47f4565
Some checks are pending
自动更新代码和重启 / update-and-restart (push) Waiting to run
CI检查 + 自动部署 / check (push) Waiting to run
CI检查 + 自动部署 / deploy (push) Blocked by required conditions
重启聊天服务 / restart (push) Waiting to run
chore: import sanitized domestic snapshot for REPO-002
Source snapshot: ca48d3ddf926d79aa138306164169baf764bb829
2026-07-17 15:54:41 +08:00

75 lines
3.1 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ═══════════════════════════════════════════════
# 🔺 Sovereign: TCS-0002∞ | Root: SYS-GLW-0001
# 📜 Copyright: 国作登字-2026-A-00037559
# ═══════════════════════════════════════════════
name: "🐕 元看门狗 · 巡检健康监控"
# ━━━ 元看门狗:极简独立 workflow监控巡检本身是否在跑 ━━━
# 设计原则:
# · 极简:不依赖任何外部脚本,只用 curl + 内联 nodePR 无法意外破坏它
# · 独立:与被监控的 workflow 完全分离
# · 写 Notion告警直接写入霜砚可读的 Notion 数据库
on:
schedule:
- cron: '0 */6 * * *' # 每6小时一次北京时间 2/8/14/20点
workflow_dispatch:
permissions:
contents: read
jobs:
check-patrol-health:
runs-on: ubuntu-latest
steps:
- name: 检查 daily-maintenance 最近运行状态
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# 用 GitHub API 查 daily-maintenance 最近一次运行时间
LAST_RUN=$(curl -s \
-H "Authorization: Bearer $GH_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/daily-maintenance.yml/runs?per_page=1&status=completed" \
| node -e "const d=require('fs').readFileSync('/dev/stdin','utf8'); \
const r=JSON.parse(d).workflow_runs && JSON.parse(d).workflow_runs[0]; \
console.log(r ? r.updated_at : 'NEVER')")
echo "daily-maintenance 最后运行:$LAST_RUN"
# 计算距上次运行的时间差,超过 26 小时则告警24h 调度周期 + 2h 缓冲)
node -e "
const last = new Date('$LAST_RUN');
const now = new Date();
const hours = (now - last) / 3600000;
if (isNaN(hours) || hours > 26) {
console.log('ALERT: daily-maintenance 已超 ' + Math.round(hours) + 'h 未运行');
process.exit(1);
} else {
console.log('OK: 距上次运行 ' + Math.round(hours) + 'h正常');
}
"
- name: 写入 Notion 告警(仅在失败时触发)
if: failure()
env:
NOTION_TOKEN: ${{ secrets.ZY_NOTION_TOKEN }}
run: |
if [ -z "$NOTION_TOKEN" ]; then
echo "⚠️ NOTION_API_KEY 未配置,跳过 Notion 告警"
exit 0
fi
curl -s -X POST https://api.notion.com/v1/pages \
-H "Authorization: Bearer $NOTION_TOKEN" \
-H "Notion-Version: 2022-06-28" \
-H "Content-Type: application/json" \
-d "{
\"parent\": {\"database_id\": \"f983bdc24b654888913ca254160bff33\"},
\"properties\": {
\"标题\": {\"title\": [{\"text\": {\"content\": \"⚠️ 元看门狗告警daily-maintenance 巡检中断\"}}]},
\"处理状态\": {\"status\": {\"name\": \"待处理\"}}
}
}"