fix notify
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 11s
Docker Build & Deploy / Deploy to Production (push) Successful in 9s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 11s
Docker Build & Deploy / Deploy to Production (push) Successful in 9s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
This commit is contained in:
@@ -99,41 +99,4 @@ jobs:
|
||||
|
||||
curl -s -X POST "$WEBHOOK_URL" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d @wechat_payload.json
|
||||
|
||||
notify:
|
||||
name: WeChat Notification
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build, deploy, cleanup]
|
||||
if: always()
|
||||
steps:
|
||||
- name: Send WeChat Notification
|
||||
run: |
|
||||
# 判断整体结果
|
||||
if [[ "${{ needs.build.result }}" == "success" && "${{ needs.deploy.result }}" == "success" ]]; then
|
||||
MSG_TITLE="构建并部署成功"
|
||||
RESULT_ICON="✅"
|
||||
MSG_COLOR="info"
|
||||
else
|
||||
MSG_TITLE="自动部署发现异常"
|
||||
RESULT_ICON="❌"
|
||||
MSG_COLOR="warning"
|
||||
fi
|
||||
|
||||
WEBHOOK_URL="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=96f9fa23-a959-4492-ac3a-7415fae19680"
|
||||
|
||||
# 准备 Markdown 内容
|
||||
# 使用 heredoc 简化 JSON 生成
|
||||
cat <<EOF > wechat_payload.json
|
||||
{
|
||||
"msgtype": "markdown",
|
||||
"markdown": {
|
||||
"content": "### $RESULT_ICON $MSG_TITLE\n> **项目名称**: [${{ gitea.repository }}](${{ gitea.server_url }}/${{ gitea.repository }})\n> **流水线**: ${{ gitea.workflow }}\n> **运行编号**: [#${{ gitea.run_number }}](${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }})\n> **状态**: <font color=\"$MSG_COLOR\">$MSG_TITLE</font>\n> **分支**: \`${{ gitea.ref_name }}\`\n> **触发者**: ${{ gitea.actor }}\n> **提交详情**: [${{ gitea.sha }}](${{ gitea.server_url }}/${{ gitea.repository }}/commit/${{ gitea.sha }})"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
# 发送请求
|
||||
curl -s -X POST "\$WEBHOOK_URL" \\
|
||||
-H "Content-Type: application/json" \\
|
||||
-d @wechat_payload.json
|
||||
Reference in New Issue
Block a user