fix(cd): 修補中文 commit message 導致 Notify Pipeline 400
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled

PYTHONIOENCODING=utf-8 確保 python3 stdin 正確解碼 UTF-8
影響 Notify Pipeline Start + Notify Pipeline Failure 兩個 step

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-12 17:35:00 +08:00
parent a1691c41d5
commit dd1b5a4364

View File

@@ -63,9 +63,12 @@ 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\":$(echo "$MSG" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))')}"
-d "{\"chat_id\":\"${{ secrets.TELEGRAM_CHAT_ID }}\",\"text\":${JSON_TEXT}}"
@@ -566,6 +569,8 @@ 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\":$(echo "$MSG" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))')}"
-d "{\"chat_id\":\"${{ secrets.TELEGRAM_CHAT_ID }}\",\"text\":${JSON_TEXT}}"