fix(cd): 用 jq 建 JSON 修復中文 commit message 400
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 16m14s

python3 stdin 與 data-urlencode 兩種方式均在 runner 失敗
jq --arg 直接接收 shell 變數,正確序列化 Unicode

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-12 18:02:06 +08:00
parent 587d745a50
commit 7fc1e0a767

View File

@@ -63,11 +63,10 @@ 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: 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@-"
# 2026-04-12 ogt: 用 jq 建 JSON正確處理中文 commit messagepython3 stdin 與 data-urlencode 均失敗)
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}')"
@@ -568,7 +567,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 — 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@-"
# 2026-04-12 ogt: 同 Notify Pipeline Start — 用 jq 建 JSON
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}')"