feat(ci): upgrade Telegram notification UX with HTML + Inline Keyboard
- Replace flat text format with structured HTML layout - Add emoji section headers and visual separators - Replace raw URLs with Inline Keyboard buttons - Success: "查看部署紀錄" + "開啟正式站" buttons - Failure: Only "查看部署紀錄" button - Use JSON payload for proper Telegram API formatting Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
35
.github/workflows/deploy-prod.yml
vendored
35
.github/workflows/deploy-prod.yml
vendored
@@ -269,14 +269,41 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Send Telegram Notification
|
||||
# 沿用 AIOPS 寫法:直接寫 Token (Self-Hosted Runner 內網安全)
|
||||
# Phase 8: 升級為結構化 HTML + Inline Keyboard UX
|
||||
run: |
|
||||
STATUS="${{ steps.status.outputs.status }}"
|
||||
BUILD_TAG="${{ needs.build.outputs.image_tag }}"
|
||||
SHORT_SHA="${{ github.sha }}"
|
||||
SHORT_SHA="${SHORT_SHA:0:7}"
|
||||
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
||||
if [ "$STATUS" = "success" ]; then EMOJI="✅"; MSG="部署成功"; else EMOJI="❌"; MSG="部署失敗"; fi
|
||||
TEXT="${EMOJI} AWOOOI ${MSG} | Env: Prod | Tag: ${BUILD_TAG} | Actor: ${{ github.actor }} | ${RUN_URL}"
|
||||
curl -s -X POST "https://api.telegram.org/bot8569720657:AAHdvKf_P2ms-QKFTyqTLtLiqEggz8cpjMk/sendMessage" -d chat_id="5619078117" -d text="${TEXT}"
|
||||
ACTOR="${{ github.actor }}"
|
||||
|
||||
# 根據狀態設定 Emoji 與標題
|
||||
if [ "$STATUS" = "success" ]; then
|
||||
EMOJI="✅"
|
||||
TITLE="部署成功"
|
||||
elif [ "$STATUS" = "warning" ]; then
|
||||
EMOJI="⚠️"
|
||||
TITLE="部署警告"
|
||||
else
|
||||
EMOJI="❌"
|
||||
TITLE="部署失敗"
|
||||
fi
|
||||
|
||||
# HTML 結構化訊息 (使用 \n 換行)
|
||||
MESSAGE="${EMOJI} <b>AWOOOI 部署通知</b>\n\n━━━━━━━━━━━━━━━━━\n📦 <b>狀態:</b> ${TITLE}\n🌍 <b>環境:</b> Production\n🏷️ <b>版本:</b> <code>${BUILD_TAG}</code>\n🔗 <b>Commit:</b> <code>${SHORT_SHA}</code>\n👤 <b>觸發者:</b> ${ACTOR}\n━━━━━━━━━━━━━━━━━"
|
||||
|
||||
# Inline Keyboard 按鈕 (成功時多一個按鈕)
|
||||
if [ "$STATUS" = "success" ]; then
|
||||
KEYBOARD='{"inline_keyboard":[[{"text":"📋 查看部署紀錄","url":"'"${RUN_URL}"'"},{"text":"🚀 開啟正式站","url":"https://awoooi.wooo.work"}]]}'
|
||||
else
|
||||
KEYBOARD='{"inline_keyboard":[[{"text":"📋 查看部署紀錄","url":"'"${RUN_URL}"'"}]]}'
|
||||
fi
|
||||
|
||||
# 發送 Telegram 訊息 (JSON payload with HTML + Inline Keyboard)
|
||||
curl -s -X POST "https://api.telegram.org/bot8569720657:AAHdvKf_P2ms-QKFTyqTLtLiqEggz8cpjMk/sendMessage" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"chat_id\":\"5619078117\",\"text\":\"${MESSAGE}\",\"parse_mode\":\"HTML\",\"reply_markup\":${KEYBOARD}}"
|
||||
|
||||
- name: Send OpenClaw Webhook
|
||||
if: always()
|
||||
|
||||
Reference in New Issue
Block a user