fix(cd): CI/CD Telegram 通知改用 HTML 結構化格式
Deploy Start / Failure 從純文字 pipe 格式改為: 🚀 AWOOOI 部署開始 ├ 📝 <commit> ├ 🔖 <sha> └ 👤 <actor> commit message 做 HTML escape 防特殊字元 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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; s/>/\>/g')
|
||||
MSG="🚀 <b>AWOOOI 部署開始</b>
|
||||
├ 📝 <code>${COMMIT_ESC}</code>
|
||||
├ 🔖 <code>${SHORT_SHA}</code>
|
||||
└ 👤 ${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; s/>/\>/g')
|
||||
MSG="❌ <b>AWOOOI 部署失敗</b>
|
||||
├ 📝 <code>${COMMIT_ESC}</code>
|
||||
├ 🔖 <code>${SHORT_SHA}</code>
|
||||
├ 👤 ${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"}')"
|
||||
|
||||
Reference in New Issue
Block a user