fix(cd): 棄用 python3 JSON 序列化,改用 --data-urlencode
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled

runner 容器 Python 3.10 無法正確讀含中文的 stdin
(UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe5)
兩個 Notify step 統一改用 --data-urlencode text@-

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-12 17:43:51 +08:00
parent 38dddcc7a2
commit 80cdd36b9d

View File

@@ -63,12 +63,11 @@ jobs:
- name: Notify Pipeline Start
run: |
MSG="AWOOOI Deploy Start | ${{ steps.commit.outputs.message }} | ${{ steps.commit.outputs.short_sha }} | ${{ github.actor }}"
# 2026-04-12 ogt: 修補中文 commit message 造成 python3 stdin UTF-8 截斷 → 400
# 改用 PYTHONIOENCODING=utf-8 確保 json.dumps 正確序列化
JSON_TEXT=$(echo "$MSG" | PYTHONIOENCODING=utf-8 python3 -c 'import json,sys; print(json.dumps(sys.stdin.read().rstrip("\n")))')
curl -fS -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-H "Content-Type: application/json" \
-d "{\"chat_id\":\"${{ secrets.TELEGRAM_CHAT_ID }}\",\"text\":${JSON_TEXT}}"
# 2026-04-12 ogt: 棄用 python3 JSON 序列化(中文 commit message 在 runner 內 UTF-8 解碼失敗)
# 改用 --data-urlencode與 Notify Pipeline Success 一致
printf '%s' "$MSG" | curl -fS -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
--data-urlencode "text@-"
@@ -569,8 +568,7 @@ jobs:
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 — PYTHONIOENCODING=utf-8 修補中文 400
JSON_TEXT=$(echo "$MSG" | PYTHONIOENCODING=utf-8 python3 -c 'import json,sys; print(json.dumps(sys.stdin.read().rstrip("\n")))')
curl -fS -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-H "Content-Type: application/json" \
-d "{\"chat_id\":\"${{ secrets.TELEGRAM_CHAT_ID }}\",\"text\":${JSON_TEXT}}"
# 2026-04-12 ogt: 同 Notify Pipeline Start — 棄用 python3改用 --data-urlencode
printf '%s' "$MSG" | curl -fS -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
--data-urlencode "text@-"