forked from badging/badging-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
githubBot.js
52 lines (46 loc) · 1.39 KB
/
githubBot.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
49
50
51
52
const {
welcome,
getResults,
// TODO: implement the help automation,
endReview,
assignChecklist,
updateReadme,
} = require("./src/logic/index");
const githubBot = async (name, octokit, payload) => {
// perform actions on application issues only
if (payload.issue.title.match(/event/i)) {
// when applicant issue is open, welcome the applicant
if (name === "issues" && payload.action === "opened") {
welcome(octokit, payload);
}
// when issue is assigned, triger the assign algorithm
if (name === "issues" && payload.action === "assigned") {
assignChecklist(octokit, payload);
}
// comment commands
if (name === "issue_comment" && payload.action === "created") {
// get results
if (payload.comment.body.match("/result")) {
getResults(octokit, payload);
}
// end review
if (payload.comment.body.match("/end")) {
endReview(octokit, payload);
}
}
// when issue is closed, update the readme with the event
if (name === "issues" && payload.action === "closed") {
updateReadme(octokit, payload);
}
} else if (
name === "installation" &&
payload.action === "new_permissions_accepted"
) {
console.info("New permissions accepted");
} else {
console.info(
`Webhook: ${name}.${payload.action} not yet automated or needed`
);
}
};
module.exports = githubBot;