From d4445c053d05b1c9a81b7373b409516bdfc68937 Mon Sep 17 00:00:00 2001 From: ren Date: Thu, 16 Oct 2025 09:52:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20gitea=20action=20?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/dingtalk-actioncard.yml | 84 ++++++++++++++++++++++++ .gitea/workflows/dingtalk-feedcard.yml | 44 +++++++++++++ .gitea/workflows/dingtalk-link.yml | 60 +++++++++++++++++ .gitea/workflows/dingtalk-markdown.yml | 53 +++++++++++++++ .gitea/workflows/dingtalk-text.yml | 52 +++++++++++++++ 5 files changed, 293 insertions(+) create mode 100644 .gitea/workflows/dingtalk-actioncard.yml create mode 100644 .gitea/workflows/dingtalk-feedcard.yml create mode 100644 .gitea/workflows/dingtalk-link.yml create mode 100644 .gitea/workflows/dingtalk-markdown.yml create mode 100644 .gitea/workflows/dingtalk-text.yml diff --git a/.gitea/workflows/dingtalk-actioncard.yml b/.gitea/workflows/dingtalk-actioncard.yml new file mode 100644 index 0000000..fc715b9 --- /dev/null +++ b/.gitea/workflows/dingtalk-actioncard.yml @@ -0,0 +1,84 @@ +name: DingTalk ActionCard Notification + +on: + workflow_dispatch: + inputs: + webhook_url: + description: "钉钉机器人 Webhook URL" + required: true + type: string + mode: + description: "ActionCard 模式 (single 或 multiple)" + required: true + type: choice + options: + - "single" + - "multiple" + default: "single" + title: + description: "消息标题" + required: true + default: "示例 ActionCard 标题" + type: string + content: + description: "消息内容" + required: true + default: "这是一个手动触发的 ActionCard 示例消息" + type: string + single_title: + description: "单按钮标题 (single 模式)" + required: false + default: "查看详情" + type: string + single_url: + description: "单按钮链接 (single 模式)" + required: false + default: "https://example.com" + type: string + btn_orientation: + description: "按钮排列方向 (multiple 模式,'0'=垂直, '1'=水平)" + required: false + default: "0" + type: string + buttons: + description: "多按钮 JSON 数组 (multiple 模式)" + required: false + default: | + [ + {"title": "查看工作流", "actionURL": "https://example.com/workflows"}, + {"title": "查看仓库", "actionURL": "https://example.com/repo"} + ] + type: string + +env: + DINGTALK_WEBHOOK: ${{ github.event.inputs.webhook_url }} + +jobs: + send-actioncard: + runs-on: ubuntu-latest + name: 发送 ActionCard 消息 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: 单按钮 ActionCard (single) + if: ${{ github.event.inputs.mode == 'single' }} + uses: ./ + with: + webhook_url: ${{ env.DINGTALK_WEBHOOK }} + message_type: actionCard + title: ${{ github.event.inputs.title }} + content: ${{ github.event.inputs.content }} + single_title: ${{ github.event.inputs.single_title }} + single_url: ${{ github.event.inputs.single_url }} + + - name: 多按钮 ActionCard (multiple) + if: ${{ github.event.inputs.mode == 'multiple' }} + uses: ./ + with: + webhook_url: ${{ env.DINGTALK_WEBHOOK }} + message_type: actionCard + title: ${{ github.event.inputs.title }} + content: ${{ github.event.inputs.content }} + btn_orientation: ${{ github.event.inputs.btn_orientation }} + buttons: ${{ github.event.inputs.buttons }} diff --git a/.gitea/workflows/dingtalk-feedcard.yml b/.gitea/workflows/dingtalk-feedcard.yml new file mode 100644 index 0000000..06ac88a --- /dev/null +++ b/.gitea/workflows/dingtalk-feedcard.yml @@ -0,0 +1,44 @@ +name: DingTalk FeedCard Notification + +on: + workflow_dispatch: + inputs: + webhook_url: + description: "钉钉机器人 Webhook URL" + required: true + type: string + feed_links: + description: "FeedCard 链接 JSON 数组" + required: true + default: | + [ + { + "title": "示例工作流", + "messageURL": "https://example.com/workflow", + "picURL": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" + }, + { + "title": "示例仓库", + "messageURL": "https://example.com/repo", + "picURL": "https://avatars.githubusercontent.com/u/9919?s=200&v=4" + } + ] + type: string + +env: + DINGTALK_WEBHOOK: ${{ github.event.inputs.webhook_url }} + +jobs: + send-feedcard: + runs-on: ubuntu-latest + name: 发送 FeedCard 消息 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: 发送 FeedCard + uses: ./ + with: + webhook_url: ${{ env.DINGTALK_WEBHOOK }} + message_type: feedCard + feed_links: ${{ github.event.inputs.feed_links }} diff --git a/.gitea/workflows/dingtalk-link.yml b/.gitea/workflows/dingtalk-link.yml new file mode 100644 index 0000000..41c9792 --- /dev/null +++ b/.gitea/workflows/dingtalk-link.yml @@ -0,0 +1,60 @@ +name: DingTalk Link Notification + +on: + workflow_dispatch: + inputs: + webhook_url: + description: "钉钉机器人 Webhook URL" + required: true + type: string + title: + description: "链接消息标题" + required: true + default: "示例链接标题" + type: string + content: + description: "链接消息描述" + required: true + default: "这是一个手动触发的链接消息示例" + type: string + link_url: + description: "链接地址" + required: true + default: "https://example.com" + type: string + pic_url: + description: "图片地址 (可选)" + required: false + default: "" + type: string + +env: + DINGTALK_WEBHOOK: ${{ github.event.inputs.webhook_url }} + +jobs: + send-link: + runs-on: ubuntu-latest + name: 发送链接消息 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: 发送基础链接消息 + uses: ./ + with: + webhook_url: ${{ env.DINGTALK_WEBHOOK }} + message_type: link + title: ${{ github.event.inputs.title }} + content: ${{ github.event.inputs.content }} + link_url: ${{ github.event.inputs.link_url }} + + - name: 发送带图片的链接消息 + if: ${{ github.event.inputs.pic_url != '' }} + uses: ./ + with: + webhook_url: ${{ env.DINGTALK_WEBHOOK }} + message_type: link + title: ${{ github.event.inputs.title }} + content: ${{ github.event.inputs.content }} + link_url: ${{ github.event.inputs.link_url }} + pic_url: ${{ github.event.inputs.pic_url }} diff --git a/.gitea/workflows/dingtalk-markdown.yml b/.gitea/workflows/dingtalk-markdown.yml new file mode 100644 index 0000000..ef82a83 --- /dev/null +++ b/.gitea/workflows/dingtalk-markdown.yml @@ -0,0 +1,53 @@ +name: DingTalk Markdown Notification + +on: + workflow_dispatch: + inputs: + webhook_url: + description: "钉钉机器人 Webhook URL" + required: true + type: string + title: + description: "消息标题" + required: true + default: "示例 Markdown 标题" + type: string + content: + description: "Markdown 消息内容" + required: true + default: "这是一个手动触发的 Markdown 示例消息" + type: string + at_mobiles: + description: "@指定手机号 (可选,多个用逗号分隔)" + required: false + default: "" + type: string + +env: + DINGTALK_WEBHOOK: ${{ github.event.inputs.webhook_url }} + +jobs: + send-markdown: + runs-on: ubuntu-latest + name: 发送 Markdown 消息 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: 发送基础 Markdown 消息 + uses: ./ + with: + webhook_url: ${{ env.DINGTALK_WEBHOOK }} + message_type: markdown + title: ${{ github.event.inputs.title }} + content: ${{ github.event.inputs.content }} + + - name: 带@功能的 Markdown 消息 + if: ${{ github.event.inputs.at_mobiles != '' }} + uses: ./ + with: + webhook_url: ${{ env.DINGTALK_WEBHOOK }} + message_type: markdown + title: ${{ github.event.inputs.title }} + content: ${{ github.event.inputs.content }} + at_mobiles: ${{ github.event.inputs.at_mobiles }} diff --git a/.gitea/workflows/dingtalk-text.yml b/.gitea/workflows/dingtalk-text.yml new file mode 100644 index 0000000..9dab15d --- /dev/null +++ b/.gitea/workflows/dingtalk-text.yml @@ -0,0 +1,52 @@ +name: DingTalk Text Notification + +on: + workflow_dispatch: + inputs: + webhook_url: + description: "钉钉机器人 Webhook URL" + required: true + type: string + content: + description: "文本消息内容" + required: true + default: "手动触发的文本消息示例" + type: string + at_mobiles: + description: "@指定手机号 (可选,多个用逗号分隔)" + required: false + default: "" + type: string + at_all: + description: "是否@所有人" + required: false + default: false + type: boolean + +env: + DINGTALK_WEBHOOK: ${{ github.event.inputs.webhook_url }} + +jobs: + send-text: + runs-on: ubuntu-latest + name: 发送文本消息 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: 发送基础文本消息 + uses: ./ + with: + webhook_url: ${{ env.DINGTALK_WEBHOOK }} + message_type: text + content: ${{ github.event.inputs.content }} + + - name: 带@功能的文本消息 + if: ${{ github.event.inputs.at_mobiles != '' || github.event.inputs.at_all == 'true' }} + uses: ./ + with: + webhook_url: ${{ env.DINGTALK_WEBHOOK }} + message_type: text + content: ${{ github.event.inputs.content }} + at_mobiles: ${{ github.event.inputs.at_mobiles }} + at_all: ${{ github.event.inputs.at_all }}