From c6fb87b7267bedc678c2bc530433f62e4a7ab6ea Mon Sep 17 00:00:00 2001 From: shaw Date: Sun, 20 Jul 2025 00:47:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=B7=A5=E4=BD=9C=E6=B5=81=E7=9A=84=20YAML?= =?UTF-8?q?=20=E8=AF=AD=E6=B3=95=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用 heredoc 语法避免多行字符串中的转义问题 - 使用 jq 工具正确构建 JSON 数据 - 修复了第 170 行的 YAML 语法错误 --- .github/workflows/auto-release.yml | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index a8320e50..8559a226 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -162,8 +162,9 @@ jobs: CHANGELOG_TRUNCATED="${CHANGELOG_TRUNCATED}..." fi - # 构建消息 - MESSAGE="🚀 *Claude Relay Service 新版本发布!* + # 构建消息,使用 JSON 格式避免转义问题 + MESSAGE=$(cat <<-ENDMSG +🚀 *Claude Relay Service 新版本发布!* 📦 版本号: \`${VERSION}\` @@ -181,16 +182,22 @@ docker pull weishaw/claude-relay-service:latest • [完整更新日志](https://github.com/${REPO}/blob/main/CHANGELOG.md) • [Docker Hub](https://hub.docker.com/r/weishaw/claude-relay-service) -#ClaudeRelay #Update #v${VERSION//./_}" +#ClaudeRelay #Update #v${VERSION//./_} +ENDMSG + ) + + # 准备 JSON 数据 + JSON_DATA=$(jq -n \ + --arg chat_id "${TELEGRAM_CHAT_ID}" \ + --arg text "${MESSAGE}" \ + '{ + chat_id: $chat_id, + text: $text, + parse_mode: "Markdown", + disable_web_page_preview: false + }') # 发送消息到 Telegram curl -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \ -H "Content-Type: application/json" \ - -d @- << EOF - { - "chat_id": "${TELEGRAM_CHAT_ID}", - "text": "${MESSAGE}", - "parse_mode": "Markdown", - "disable_web_page_preview": false - } - EOF \ No newline at end of file + -d "${JSON_DATA}" \ No newline at end of file