Files
ant-design/.github/workflows/issue-schedule.yml
blacksmith-sh[bot] 38efd012a2 .github/workflows: Migrate workflows to Blacksmith runners (#56282)
* Migrate workflows to Blacksmith

* Update .github/workflows/preview-build.yml

Signed-off-by: thinkasany <480968828@qq.com>

* preview-build.yml use runs-on: ubuntu-latest (#56367)

* Initial plan

* fix: add named exports for ColorPalettes and ColorPaletteToolDark to fix SSR compatibility

Co-authored-by: thinkasany <117748716+thinkasany@users.noreply.github.com>

* test: preview-build use ubuntu-latest

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: thinkasany <117748716+thinkasany@users.noreply.github.com>
Co-authored-by: thinkasany <480968828@qq.com>

---------

Signed-off-by: thinkasany <480968828@qq.com>
Co-authored-by: blacksmith-sh[bot] <157653362+blacksmith-sh[bot]@users.noreply.github.com>
Co-authored-by: afc163 <afc163@gmail.com>
Co-authored-by: thinkasany <480968828@qq.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: thinkasany <117748716+thinkasany@users.noreply.github.com>
2025-12-30 23:04:15 +08:00

99 lines
3.8 KiB
YAML

name: Issue Schedule
on:
workflow_dispatch:
schedule:
- cron: '30 1 * * *'
jobs:
send-message:
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- name: Send Unconfirmed Issues to DingTalk
uses: actions/github-script@v8
env:
DINGDING_BOT_TOKEN: ${{ secrets.DINGDING_BOT_COLLABORATOR_TOKEN }}
actionTitle: 近 7 天未确认的 issue
with:
script: |
const dingdingTokenKey = process.env.DINGDING_BOT_TOKEN;
const fromNow = (data) => {
const relativeTimeFormat = new Intl.RelativeTimeFormat('zh-CN');
const date = new Date(data);
const now = new Date();
const diffInSeconds = Math.floor((now - date) / 1000);
const diffInMinutes = Math.floor(diffInSeconds / 60);
const diffInHours = Math.floor(diffInMinutes / 60);
const diffInDays = Math.floor(diffInHours / 24);
if (diffInDays > 0) {
return relativeTimeFormat.format(-diffInDays, 'day');
} else if (diffInHours > 0) {
return relativeTimeFormat.format(-diffInHours, 'hour');
} else if (diffInMinutes > 0) {
return relativeTimeFormat.format(-diffInMinutes, 'minute');
} else {
return relativeTimeFormat.format(-diffInSeconds, 'second');
}
};
const response = await fetch('https://api.github.com/search/issues?q=repo:ant-design/ant-design&is:open+is:issue+label:unconfirmed&per_page=100');
const data = await response.json();
const issueList = [];
for (const item of data.items) {
const { created_at, html_url, pull_request, state, title, labels, number } = item;
const createdAt = new Date(created_at);
const now = new Date();
const diffTime = Math.abs(now - createdAt);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
const isUnconfirmed = labels.some(label => label.name === 'unconfirmed');
if (!isUnconfirmed) {
continue;
}
if (diffDays > 7) {
break;
}
if (!pull_request && !html_url.includes('pull') && state === 'open') {
issueList.push({
number,
html_url,
created_at,
title
})
}
}
const actionTitle = process.env.actionTitle + `(${issueList.length})`;
const markdownList = `## ${actionTitle}\n\n`
+ issueList.map(issue => `- ${fromNow(issue.created_at)} [#${issue.number} ${issue.title}](${issue.html_url})`).join('\n')
+ `\n\n > 🫵🏻 快去帮忙处理吧,社区需要你的帮助!`;
console.log(markdownList);
try {
await fetch(
`https://oapi.dingtalk.com/robot/send?access_token=${dingdingTokenKey}`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
msgtype: 'markdown',
markdown: {
title: actionTitle,
text: markdownList,
},
}),
}
);
} catch (error) {
console.log('发送失败, error:', error);
}