From 1b4ff3cd7aa46b1ef10de9917e784cb63ab90666 Mon Sep 17 00:00:00 2001 From: WrBug Date: Mon, 30 Mar 2026 12:58:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=E5=8A=A0=E5=9B=BA=E5=90=88=E5=B9=B6?= =?UTF-8?q?=20PR=20=E5=90=8E=20Telegram=20=E9=80=9A=E7=9F=A5=E6=AD=A5?= =?UTF-8?q?=E9=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 Issue 元数据经 env 注入,并用 jq 组装 MESSAGE,避免标题中的引号、 换行或 shell 元字符破坏生成的 run 脚本或正文拼接。 Made-with: Cursor --- .github/workflows/close-issue-on-pr-merge.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/close-issue-on-pr-merge.yml b/.github/workflows/close-issue-on-pr-merge.yml index 9e2d126..5ba88dc 100644 --- a/.github/workflows/close-issue-on-pr-merge.yml +++ b/.github/workflows/close-issue-on-pr-merge.yml @@ -91,6 +91,11 @@ jobs: env: TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} + # 经 env 注入,避免 Issue 标题等含引号/换行/$ 时被写入 run 脚本导致截断或语法错误 + ISSUE_NUM: ${{ steps.pr.outputs.ISSUE_NUMBER }} + ISSUE_TITLE: ${{ steps.issue.outputs.title }} + ISSUE_URL: ${{ steps.issue.outputs.url }} + PR_URL: ${{ github.event.pull_request.html_url }} run: | # 与 docker-build 一致:未配置则跳过 if [ -z "$TELEGRAM_BOT_TOKEN" ] || [ -z "$TELEGRAM_CHAT_ID" ]; then @@ -98,13 +103,12 @@ jobs: exit 0 fi - ISSUE_NUM="${{ steps.pr.outputs.ISSUE_NUMBER }}" - ISSUE_TITLE="${{ steps.issue.outputs.title }}" - ISSUE_URL="${{ steps.issue.outputs.url }}" - PR_URL="${{ github.event.pull_request.html_url }}" - - # 与 docker-build 相同的 HTML 消息格式 - MESSAGE="✅ AI 修复的 Issue 已关闭"$'\n'$'\n'"🔢 Issue: #${ISSUE_NUM} ${ISSUE_TITLE}"$'\n'"📎 查看 Issue"$'\n'"🔗 查看 PR" + MESSAGE=$(jq -n -r \ + --arg num "$ISSUE_NUM" \ + --arg title "$ISSUE_TITLE" \ + --arg iu "$ISSUE_URL" \ + --arg pu "$PR_URL" \ + '"✅ AI 修复的 Issue 已关闭\n\n🔢 Issue: #" + $num + " " + $title + "\n📎 查看 Issue\n🔗 查看 PR"') curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \ -H "Content-Type: application/json" \