fix(ci): make Telegram notifications non-blocking on CD pipeline
Some checks failed
CD Pipeline / tests (push) Failing after 1m27s
CD Pipeline / build-and-deploy (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped
Code Review / ai-code-review (push) Successful in 48s

統帥鐵證:tests/build-and-deploy 步驟內 'Notify Pipeline Start/Failure'
curl 400 → 整個 job exit 22 → 從 5/1 起連續 14 個 commit 部署被擋。

根本問題:通知步驟是觀察用,不該成為 CI 主流程的 hard requirement。
curl -fS 預設 fail-on-HTTP-error,配上 Telegram bot 任何短暫故障
(token revoke、bot 被踢出 chat、API rate limit)就把整條 pipeline 擊垮。

修法:對齊 line 922 既有正確 pattern,5 處 curl 全部加
`|| echo "TG notify failed (non-fatal): exit=$?"`

涉及 step:
- Notify Pipeline Start (line 79)
- Notify Pipeline Failure × tests (line 236)
- Notify Pipeline Failure × build-and-deploy (line 779)
- Notify Pipeline Failure × post-deploy-checks (line 938)
- (line 924 已是正確 pattern, 不動)

副效應:notification 失敗從此只會在 log 留 warning,不擋 CI。
真正的 telegram 故障由系統其他監控機制(alertmanager_health 等)負責。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Your Name
2026-05-03 00:00:20 +08:00
parent b710f3f38f
commit b5adf77a9f

View File

@@ -71,10 +71,12 @@ jobs:
# HTML escape commit message防特殊字元破壞 HTML
COMMIT_ESC=$(echo "$COMMIT_MSG" | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g')
MSG=$(printf '🚀 <b>AWOOOI 部署開始</b>\n├ 📝 <code>%s</code>\n├ 🔖 <code>%s</code>\n└ 👤 %s' "${COMMIT_ESC}" "${SHORT_SHA}" "${ACTOR}")
# 2026-05-02 Claude Opus 4.7 + 統帥 ogt: notify 失敗不該擋整條 CI鐵證:
# curl 400 從 5/1 起連續炸 14 個 commit 的 build-and-deploy— 對齊 line 922 既有 pattern
curl -fS -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-d "chat_id=${{ env.TELEGRAM_ALERT_CHAT_ID }}" \
-d "parse_mode=HTML" \
--data-urlencode "text=${MSG}"
--data-urlencode "text=${MSG}" || echo "TG notify failed (non-fatal): exit=$?"
@@ -231,7 +233,7 @@ jobs:
curl -fS -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-d "chat_id=${{ env.TELEGRAM_ALERT_CHAT_ID }}" \
-d "parse_mode=HTML" \
--data-urlencode "text=${MSG}"
--data-urlencode "text=${MSG}" || echo "TG notify failed (non-fatal): exit=$?"
build-and-deploy:
# 2026-04-30 Codex: Docker builds run on the host runner. Long docker build
@@ -774,7 +776,7 @@ jobs:
curl -fS -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-d "chat_id=${{ env.TELEGRAM_ALERT_CHAT_ID }}" \
-d "parse_mode=HTML" \
--data-urlencode "text=${MSG}"
--data-urlencode "text=${MSG}" || echo "TG notify failed (non-fatal): exit=$?"
post-deploy-checks:
needs: build-and-deploy
@@ -933,4 +935,4 @@ jobs:
curl -fS -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-d "chat_id=${{ env.TELEGRAM_ALERT_CHAT_ID }}" \
-d "parse_mode=HTML" \
--data-urlencode "text=${MSG}"
--data-urlencode "text=${MSG}" || echo "TG notify failed (non-fatal): exit=$?"