54 lines
1.8 KiB
YAML
54 lines
1.8 KiB
YAML
# 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,
|
|
labels: (issue.labels || []).map(label => label.name).join(', ') || '无标签'
|
|
}
|
|
};
|
|
|
|
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 }}
|