chore: gitea actions
This commit is contained in:
124
.gitea/actions/wecom-notification/action.yaml
Normal file
124
.gitea/actions/wecom-notification/action.yaml
Normal file
@@ -0,0 +1,124 @@
|
||||
name: WeChat Work Notification
|
||||
description: 发送企业微信群机器人通知
|
||||
author: Your Team
|
||||
|
||||
inputs:
|
||||
webhook_url:
|
||||
description: 企业微信群机器人 Webhook URL
|
||||
required: true
|
||||
status:
|
||||
description: 构建状态 (success/failure/cancelled)
|
||||
required: true
|
||||
default: success
|
||||
title:
|
||||
description: 通知标题
|
||||
required: true
|
||||
repository:
|
||||
description: 仓库名称
|
||||
required: false
|
||||
default: ${{ github.repository }}
|
||||
branch:
|
||||
description: 分支名称
|
||||
required: false
|
||||
default: ''
|
||||
version:
|
||||
description: 版本号
|
||||
required: false
|
||||
default: ''
|
||||
actor:
|
||||
description: 构建触发人
|
||||
required: false
|
||||
default: ${{ github.actor }}
|
||||
run_number:
|
||||
description: 运行序号
|
||||
required: false
|
||||
default: ${{ github.run_number }}
|
||||
run_url:
|
||||
description: 运行详情 URL
|
||||
required: false
|
||||
default: ''
|
||||
failed_step:
|
||||
description: 失败的步骤名称
|
||||
required: false
|
||||
default: ''
|
||||
extra_content:
|
||||
description: 额外的通知内容 (markdown 格式)
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Send WeChat Work Notification
|
||||
shell: bash
|
||||
run: |
|
||||
# 设置状态图标和文本
|
||||
if [ "${{ inputs.status }}" = "success" ]; then
|
||||
STATUS_ICON="✅"
|
||||
STATUS_TEXT="成功"
|
||||
elif [ "${{ inputs.status }}" = "cancelled" ]; then
|
||||
STATUS_ICON="⚠️"
|
||||
STATUS_TEXT="已取消"
|
||||
else
|
||||
STATUS_ICON="❌"
|
||||
STATUS_TEXT="失败"
|
||||
fi
|
||||
|
||||
# 构建通知内容
|
||||
CONTENT="## ${STATUS_ICON} ${{ inputs.title }} ${STATUS_TEXT}"
|
||||
|
||||
# 添加仓库信息
|
||||
if [ -n "${{ inputs.repository }}" ]; then
|
||||
CONTENT="${CONTENT}\n> **仓库**: ${{ inputs.repository }}"
|
||||
fi
|
||||
|
||||
# 添加分支信息
|
||||
if [ -n "${{ inputs.branch }}" ]; then
|
||||
CONTENT="${CONTENT}\n> **分支**: ${{ inputs.branch }}"
|
||||
fi
|
||||
|
||||
# 添加版本信息
|
||||
if [ -n "${{ inputs.version }}" ]; then
|
||||
CONTENT="${CONTENT}\n> **版本**: ${{ inputs.version }}"
|
||||
fi
|
||||
|
||||
# 添加构建人
|
||||
if [ -n "${{ inputs.actor }}" ]; then
|
||||
CONTENT="${CONTENT}\n> **构建人**: ${{ inputs.actor }}"
|
||||
fi
|
||||
|
||||
# 添加运行序号
|
||||
if [ -n "${{ inputs.run_number }}" ]; then
|
||||
CONTENT="${CONTENT}\n> **运行序号**: #${{ inputs.run_number }}"
|
||||
fi
|
||||
|
||||
# 添加失败步骤信息
|
||||
if [ -n "${{ inputs.failed_step }}" ]; then
|
||||
CONTENT="${CONTENT}\n> **失败步骤**: ${{ inputs.failed_step }}"
|
||||
fi
|
||||
|
||||
# 添加额外内容
|
||||
if [ -n "${{ inputs.extra_content }}" ]; then
|
||||
CONTENT="${CONTENT}\n> ${{ inputs.extra_content }}"
|
||||
fi
|
||||
|
||||
# 添加查看详情链接
|
||||
if [ -n "${{ inputs.run_url }}" ]; then
|
||||
CONTENT="${CONTENT}\n> [查看详情](${{ inputs.run_url }})"
|
||||
fi
|
||||
|
||||
echo "========== 企业微信通知 =========="
|
||||
echo "状态: ${STATUS_ICON} ${STATUS_TEXT}"
|
||||
echo "标题: ${{ inputs.title }}"
|
||||
echo "Webhook URL: ${{ inputs.webhook_url }}"
|
||||
echo "=================================="
|
||||
|
||||
# 发送通知
|
||||
curl -s -X POST "${{ inputs.webhook_url }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"msgtype\": \"markdown\",
|
||||
\"markdown\": {
|
||||
\"content\": \"${CONTENT}\"
|
||||
}
|
||||
}"
|
||||
Reference in New Issue
Block a user