Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
知鸟1号
ant-design-pro
提交
69eb71f4
A
ant-design-pro
项目概览
知鸟1号
/
ant-design-pro
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design-pro
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
69eb71f4
编写于
2月 25, 2021
作者:
C
chenshuai2144
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add auto reply issue
上级
f45c433c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
129 addition
and
0 deletion
+129
-0
.github/workflows/reply-issue.yml
.github/workflows/reply-issue.yml
+44
-0
tests/issue.js
tests/issue.js
+85
-0
未找到文件。
.github/workflows/reply-issue.yml
0 → 100644
浏览文件 @
69eb71f4
name
:
auto issue
on
:
issues
:
types
:
[
opened
]
jobs
:
reply
:
runs-on
:
ubuntu-latest
steps
:
-
uses
:
actions/checkout@v2
-
name
:
Use Node.js ${{ matrix.node_version }}
uses
:
actions/setup-node@v1
with
:
node-version
:
${{ matrix.node_version }}
-
name
:
Get yarn cache directory path
id
:
yarn-cache-dir-path
run
:
echo "::set-output name=dir::$(yarn cache dir)"
-
name
:
Cache yarn cache
uses
:
actions/cache@v2
id
:
cache-yarn-cache
with
:
path
:
${{ steps.yarn-cache-dir-path.outputs.dir }}
key
:
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys
:
|
${{ runner.os }}-yarn-
-
name
:
Cache node_modules
id
:
cache-node-modules
uses
:
actions/cache@v2
with
:
path
:
node_modules
key
:
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
restore-keys
:
|
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
-
run
:
yarn --ignore-engines
if
:
|
steps.cache-yarn-cache.outputs.cache-hit != 'true' ||
steps.cache-node-modules.outputs.cache-hit != 'true'
-
run
:
yarn add @octokit/core
-
name
:
Auto reply to issue
env
:
GITHUB_TOKEN
:
${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER
:
${{ github.event.issue.number }}
run
:
node ./tests/issue.js
tests/issue.js
0 → 100644
浏览文件 @
69eb71f4
const
Octokit
=
require
(
'
@octokit/core
'
);
const
octokit
=
new
Octokit
.
Octokit
({
auth
:
process
.
env
.
GITHUB_TOKEN
||
process
.
env
.
GITHUB_AUTH
,
});
const
queryIssue
=
({
title
,
id
})
=>
{
return
octokit
.
request
(
'
GET /search/issues
'
,
{
q
:
title
,
per_page
:
5
,
})
.
then
(({
data
})
=>
{
const
list
=
data
.
items
.
map
((
item
)
=>
{
return
{
title
:
item
.
title
,
url
:
item
.
html_url
,
id
:
item
.
id
,
};
})
.
filter
((
item
)
=>
{
return
item
.
id
!==
id
;
});
if
(
list
.
length
>
0
)
{
return
`
> Issue Robot generation
### 以下的issue可能会帮助到你 :
${
list
.
map
((
item
)
=>
{
return
`* [
${
item
.
title
}
](
${
item
.
url
}
)`
;
})
.
join
(
'
\n
'
)}
`
;
}
return
null
;
})
.
then
(
async
(
markdown
)
=>
{
return
markdown
;
});
};
const
findIssue
=
async
(
issueId
)
=>
{
const
{
data
}
=
await
octokit
.
request
(
'
GET /repos/{owner}/{repo}/issues/{issue_number}
'
,
{
owner
:
'
ant-design
'
,
repo
:
'
ant-design-pro
'
,
issue_number
:
issueId
,
});
return
data
;
};
const
closeIssue
=
async
(
issueId
)
=>
{
await
octokit
.
request
(
'
PATCH /repos/{owner}/{repo}/issues/{issue_number}
'
,
{
owner
:
'
ant-design
'
,
repo
:
'
ant-design-pro
'
,
issue_number
:
issueId
,
state
:
'
closed
'
,
});
};
const
replyCommit
=
async
(
issueId
,
markdown
)
=>
{
await
octokit
.
request
(
'
POST /repos/{owner}/{repo}/issues/{issue_number}/comments
'
,
{
owner
:
'
ant-design
'
,
repo
:
'
ant-design-pro
'
,
issue_number
:
issueId
,
body
:
markdown
,
});
};
const
reply
=
async
()
=>
{
const
issueId
=
process
.
env
.
ISSUE_NUMBER
;
const
issue
=
await
findIssue
(
issueId
);
if
(
!
issue
.
title
||
issue
.
title
.
length
<
6
)
{
replyCommit
(
issueId
,
'
**请写标题!**
'
);
closeIssue
(
issueId
);
return
;
}
const
markdown
=
await
queryIssue
({
title
:
issue
.
title
,
id
:
issue
.
id
,
});
replyCommit
(
issueId
,
markdown
);
};
reply
();
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录