From 5ee76dc30d98c08853a84d8b97bb712d25ee7e7f Mon Sep 17 00:00:00 2001 From: OG T Date: Thu, 16 Apr 2026 03:04:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(cd):=20CI/CD=20Telegram=20=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=94=B9=E7=94=A8=20HTML=20=E7=B5=90=E6=A7=8B?= =?UTF-8?q?=E5=8C=96=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deploy Start / Failure 從純文字 pipe 格式改為: 🚀 AWOOOI 部署開始 ├ 📝 ├ 🔖 └ 👤 commit message 做 HTML escape 防特殊字元 Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/cd.yaml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml index 87b26386..93d8aa78 100644 --- a/.gitea/workflows/cd.yaml +++ b/.gitea/workflows/cd.yaml @@ -61,12 +61,20 @@ jobs: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT - name: Notify Pipeline Start + # 2026-04-16 ogt + Claude Sonnet 4.6: 改用 HTML 結構化格式,提升可讀性 run: | - MSG="AWOOOI Deploy Start | ${{ steps.commit.outputs.message }} | ${{ steps.commit.outputs.short_sha }} | ${{ github.actor }}" - # 2026-04-12 ogt: 用 jq 建 JSON,正確處理中文 commit message(python3 stdin 與 data-urlencode 均失敗) + COMMIT_MSG="${{ steps.commit.outputs.message }}" + SHORT_SHA="${{ steps.commit.outputs.short_sha }}" + ACTOR="${{ github.actor }}" + # HTML escape commit message(防特殊字元破壞 HTML) + COMMIT_ESC=$(echo "$COMMIT_MSG" | sed 's/&/\&/g; s//\>/g') + MSG="🚀 AWOOOI 部署開始 +├ 📝 ${COMMIT_ESC} +├ 🔖 ${SHORT_SHA} +└ 👤 ${ACTOR}" curl -fS -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \ -H "Content-Type: application/json" \ - -d "$(jq -n --arg c "${{ secrets.TELEGRAM_CHAT_ID }}" --arg t "$MSG" '{chat_id:$c,text:$t}')" + -d "$(jq -n --arg c "${{ secrets.TELEGRAM_CHAT_ID }}" --arg t "$MSG" '{chat_id:$c,text:$t,parse_mode:"HTML"}')" @@ -565,10 +573,18 @@ jobs: --data-urlencode "text@-" || echo "TG notify warning (non-fatal)" - name: Notify Pipeline Failure + # 2026-04-16 ogt + Claude Sonnet 4.6: 改用 HTML 結構化格式 if: failure() run: | - MSG="AWOOOI Deploy FAILED | ${{ steps.commit.outputs.message }} | ${{ steps.commit.outputs.short_sha }} | ${{ github.actor }} | http://192.168.0.110:3001/wooo/awoooi/actions" - # 2026-04-12 ogt: 同 Notify Pipeline Start — 用 jq 建 JSON + COMMIT_MSG="${{ steps.commit.outputs.message }}" + SHORT_SHA="${{ steps.commit.outputs.short_sha }}" + ACTOR="${{ github.actor }}" + COMMIT_ESC=$(echo "$COMMIT_MSG" | sed 's/&/\&/g; s//\>/g') + MSG="❌ AWOOOI 部署失敗 +├ 📝 ${COMMIT_ESC} +├ 🔖 ${SHORT_SHA} +├ 👤 ${ACTOR} +└ 🔗 http://192.168.0.110:3001/wooo/awoooi/actions" curl -fS -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \ -H "Content-Type: application/json" \ - -d "$(jq -n --arg c "${{ secrets.TELEGRAM_CHAT_ID }}" --arg t "$MSG" '{chat_id:$c,text:$t}')" + -d "$(jq -n --arg c "${{ secrets.TELEGRAM_CHAT_ID }}" --arg t "$MSG" '{chat_id:$c,text:$t,parse_mode:"HTML"}')"