ci(wechat-notify): extract payload building logic to Python script
- Create new `.github/scripts/build_wechat_payload.py` to handle WeChat payload generation - Replace inline Python string concatenation with dedicated script for better maintainability - Add checkout step to access the script during workflow execution - Simplify workflow by delegating payload construction to external script - Improve code readability and reusability for future notification enhancements
This commit is contained in:
21
.github/workflows/release-notify-wechat.yml
vendored
21
.github/workflows/release-notify-wechat.yml
vendored
@@ -79,6 +79,10 @@ jobs:
|
||||
echo "EOF" >> $GITHUB_OUTPUT
|
||||
|
||||
# 5️⃣ 企业微信通知(Markdown)
|
||||
- name: Checkout for script
|
||||
if: steps.check.outputs.ok == 'true'
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Notify WeChat
|
||||
if: steps.check.outputs.ok == 'true'
|
||||
env:
|
||||
@@ -89,22 +93,7 @@ jobs:
|
||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
||||
AI_SUMMARY: ${{ steps.ai.outputs.summary }}
|
||||
run: |
|
||||
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)
|
||||
"
|
||||
python3 .github/scripts/build_wechat_payload.py
|
||||
|
||||
curl -s "$WECHAT_WEBHOOK" \
|
||||
-H 'Content-Type: application/json' \
|
||||
|
||||
Reference in New Issue
Block a user