From 8495aa5dde784b423f5fbe9522be34a9df910e38 Mon Sep 17 00:00:00 2001 From: Ke Sun Date: Mon, 13 Apr 2026 19:18:11 +0800 Subject: [PATCH] ci(wechat-notify): replace shell string formatting with Python - Replace printf and jq command chain with Python script for payload generation - Improve readability by using Python string concatenation instead of nested printf format specifiers - Ensure proper JSON encoding with ensure_ascii=False to preserve Chinese characters - Simplify environment variable interpolation using os.environ dictionary access --- .github/workflows/release-notify-wechat.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-notify-wechat.yml b/.github/workflows/release-notify-wechat.yml index 7b3378b0..ae5f3f6e 100644 --- a/.github/workflows/release-notify-wechat.yml +++ b/.github/workflows/release-notify-wechat.yml @@ -89,11 +89,22 @@ jobs: PR_URL: ${{ github.event.pull_request.html_url }} AI_SUMMARY: ${{ steps.ai.outputs.summary }} run: | - CONTENT=$(printf '## πŸš€ Release ε‘εΈƒι€šηŸ₯\n> πŸ“¦ **εˆ†ζ”―**: %s\n> πŸ‘€ **提亀人**: %s\n> πŸ“ **ζ ‡ι’˜**: %s\n\n### 🧠 AIε˜ζ›΄ζ‘˜θ¦\n%s\n\n---\nπŸ”— [ζŸ₯ηœ‹PRθ―¦ζƒ…](%s)' \ - "$BRANCH" "$AUTHOR" "$PR_TITLE" "$AI_SUMMARY" "$PR_URL") - - jq -n --arg content "$CONTENT" \ - '{"msgtype": "markdown", "markdown": {"content": $content}}' > wechat_payload.json + python3 -c " + import json, os + content = ( + '## πŸš€ Release ε‘εΈƒι€šηŸ₯\n' + '> πŸ“¦ **εˆ†ζ”―**: ' + os.environ['BRANCH'] + '\n' + '> πŸ‘€ **提亀人**: ' + os.environ['AUTHOR'] + '\n' + '> πŸ“ **ζ ‡ι’˜**: ' + os.environ['PR_TITLE'] + '\n\n' + '### 🧠 AIε˜ζ›΄ζ‘˜θ¦\n' + + os.environ['AI_SUMMARY'] + '\n\n' + '---\n' + 'πŸ”— [ζŸ₯ηœ‹PRθ―¦ζƒ…](' + os.environ['PR_URL'] + ')' + ) + payload = {'msgtype': 'markdown', 'markdown': {'content': content}} + with open('wechat_payload.json', 'w') as f: + json.dump(payload, f, ensure_ascii=False) + " curl -s "$WECHAT_WEBHOOK" \ -H 'Content-Type: application/json' \