From b5011743a99c3137c5afd6f736ad544b0294cbf2 Mon Sep 17 00:00:00 2001 From: Misaka_Company Date: Wed, 4 Feb 2026 13:02:05 +0800 Subject: [PATCH] fix: escape special characters in commit message for NTFY Use shell variables to properly handle multi-line commit messages and special characters that cause shell parsing errors. Co-Authored-By: Claude Sonnet 4.5 --- .gitea/workflows/notify.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/notify.yml b/.gitea/workflows/notify.yml index 4bfe24f..f3ea267 100644 --- a/.gitea/workflows/notify.yml +++ b/.gitea/workflows/notify.yml @@ -7,12 +7,21 @@ jobs: steps: - name: Send to NTFY run: | - curl -d "🚀 ${{ github.repository_name }} - New commit ${{ github.sha }} + REPO="${{ github.repository_name }}" + SHA="${{ github.sha }}" + MSG="${{ github.event.head_commit.message }}" + AUTHOR="${{ github.actor }}" + BRANCH="${{ github.ref_name }}" + + # 将多行消息替换为空格,避免shell解析错误 + MSG=$(echo "$MSG" | tr '\n' ' ' | sed 's/"/\\"/g') + + curl -d "🚀 $REPO + New commit $SHA 📝 Message - ${{ github.event.head_commit.message }} - 👤 Author: ${{ github.actor }} - 🌿 Branch: ${{ github.ref_name }}" \ + $MSG + 👤 Author: $AUTHOR + 🌿 Branch: $BRANCH" \ -H "Title: Git Push Notification" \ -H "Priority: default" \ -H "Tags: gitea,push,${{ github.repository_name }}" \