generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (28 loc) · 905 Bytes
/
index.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
const core = require('@actions/core');
const gh = require('@actions/github');
// most @actions toolkit packages have async methods
async function run() {
try {
const octokit = gh.getOctokit(core.getInput('token'));
const shortcutComments = [];
for await (const {data: comments} of octokit.paginate.iterator(
octokit.rest.issues.listComments,
{
...gh.context.issue,
}
)) {
shortcutComments.push(...comments.filter(comment =>
comment.user.login === 'shortcut-integration'
))
}
if (shortcutComments.length > 1) core.setFailed("More than one shortcut comment found! Split your PR.")
const commentBody = shortcutComments[0].body;
await octokit.rest.issues.update({
...gh.context.issue,
title: commentBody.slice(commentBody.indexOf(':'))
})
} catch (error) {
core.setFailed(error.message);
}
}
run();