From dda4dacb1c56fa1ec7904db2f97eed894e549557 Mon Sep 17 00:00:00 2001 From: meng93 Date: Tue, 31 Mar 2026 17:38:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20to=20#73551688=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/issue-to-AI-table.yml | 52 +++++++++++++++++++++++++ .github/workflows/issue-to-dingtalk.yml | 49 +++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 .github/workflows/issue-to-AI-table.yml create mode 100644 .github/workflows/issue-to-dingtalk.yml diff --git a/.github/workflows/issue-to-AI-table.yml b/.github/workflows/issue-to-AI-table.yml new file mode 100644 index 00000000..8e766d5b --- /dev/null +++ b/.github/workflows/issue-to-AI-table.yml @@ -0,0 +1,52 @@ +# Issue 变更推送到 Webhook +# 当有 Issue 变更时,发送指定格式的数据到 webhook +name: 📤 Issue Webhook Notification + +on: + issues: + types: [opened, reopened, closed, edited, labeled, unlabeled] + +jobs: + notify: + runs-on: ubuntu-latest + steps: + - name: 📬 Send Issue to Webhook + uses: actions/github-script@v7 + with: + script: | + const webhook = process.env.ISSUE_WEBHOOK_URL; + if (!webhook) { + console.log('⚠️ ISSUE_WEBHOOK_URL not set, skipping notification'); + return; + } + + const payload = context.payload; + const issue = payload.issue; + const action = payload.action; + + // 构建指定格式的数据 + const webhookPayload = { + action: action, + issue: { + id: issue.id, + number: issue.number, + title: issue.title, + body: issue.body, + state: issue.state, + html_url: issue.html_url + } + }; + + const response = await fetch(webhook, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(webhookPayload) + }); + + if (response.ok) { + console.log('✅ Webhook notification sent successfully'); + } else { + console.log('❌ Failed to send webhook notification:', response.status, response.statusText); + } + env: + ISSUE_WEBHOOK_URL: ${{ secrets.DINGTALK_AI_TABLE_WEBHOOK }} diff --git a/.github/workflows/issue-to-dingtalk.yml b/.github/workflows/issue-to-dingtalk.yml new file mode 100644 index 00000000..09344730 --- /dev/null +++ b/.github/workflows/issue-to-dingtalk.yml @@ -0,0 +1,49 @@ +# Issue 自动同步到钉钉群 +# 当有新 Issue 时,自动发送到钉钉群(不包括 comment) +name: 🔔 Issue Notification to DingTalk + +on: + issues: + types: [opened, reopened, closed, labeled] + +jobs: + notify: + runs-on: ubuntu-latest + steps: + - name: 📬 Send Issue to DingTalk + uses: actions/github-script@v7 + with: + script: | + const webhook = process.env.DINGTALK_WEBHOOK; + if (!webhook) { + console.log('⚠️ DINGTALK_WEBHOOK not set, skipping notification'); + return; + } + + const payload = context.payload; + const issue = payload.issue; + const action = payload.action; + + // 构建消息标题和内容(确保包含关键字 "issue" 以支持 Custom Keywords 模式) + const title = `[${action.toUpperCase()}] Issue #${issue.number}: ${issue.title}`; + const content = issue.body?.substring(0, 500) || 'No description'; + const url = issue.html_url; + + // 消息内容必须包含关键字(如 "issue")以支持 Custom Keywords 安全模式 + const message = { + msgtype: 'markdown', + markdown: { + title: 'GitHub Issue 通知', + text: `## 🔔 GitHub Issue 通知\n\n**${title}**\n\n${content}${content.length >= 500 ? '...' : ''}\n\n[点击查看详情](${url})\n\n---\n📦 ${context.repo.owner}/${context.repo.repo}\n\n**关键词**: issue` + } + }; + + await fetch(webhook, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(message) + }); + + console.log('✅ DingTalk notification sent'); + env: + DINGTALK_WEBHOOK: ${{ secrets.DINGTALK_WEBHOOK }}