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"}')"