fix(cd): 用 jq 建 JSON 修復中文 commit message 400
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 16m14s
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:
@@ -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 message(python3 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}')"
|
||||
|
||||
Reference in New Issue
Block a user