-
Notifications
You must be signed in to change notification settings - Fork 1
/
daily-issue.js
48 lines (41 loc) · 1.36 KB
/
daily-issue.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const core = require("@actions/core");
const github = require('@actions/github');
const { exec } = require("child_process");
const { ReposChatMap } = require("./const");
const wxhook = core.getInput("wxhook");
const context = github.context;
function renderMark() {
return `> **${context.payload.action === 'reopened' ? context.payload.sender.login + '重新打开了一个issue' : '有人提issue啦'}**
> **标 题:** ${context.payload.issue.title}
> **发起人:** ${context.payload.issue.user.login}
> [查看详情](${context.payload.issue.html_url})`
}
async function send() {
console.log(context.payload)
// console.log(context.issue)// { owner: '94dreamer', repo: 'tdesign-mobile-vue', number: 9 }
// 调取 参数指定的 ReposEnum 的issue 情况
// 形成 infoData
// 灌入模版 生成图表
const markdownString = renderMark();
exec(
`curl ${wxhook} \
-H 'Content-Type: application/json' \
-d '
{
"chatid": "${ReposChatMap[context.payload.repository.name]}",
"msgtype": "markdown",
"markdown": {
"content": "${markdownString.replaceAll('"', "'")}"
}
}'`,
(error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
}
);
}
module.exports = send;