-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
90 lines (81 loc) · 2.58 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/* eslint-disable no-undef */
// SPDX-License-Identifier: ISC
const labeler = require("./lib/labeler");
const greetings = require("./lib/greetings");
const issuelink = require("./lib/issuelink");
const titleValidator = require("./lib/title_validator");
const upToDateChecker = require("./lib/up_to_date_checker");
const utils = require("./lib/utils");
module.exports = (app) => {
app.log("Yay, the app was loaded!");
app.on("*", async (context) => {
context.log({ event: context.event, action: context.payload.action });
});
// "Labeler" - Add Labels on PRs
app.on(
[
"pull_request.opened",
"pull_request.reopened",
"pull_request.edited",
"pull_request.synchronize",
],
async (context) => {
const config = await utils.getConfig(context);
await labeler.addLabelsOnPr(context, config);
}
);
// "Greetings" - Welcome Authors on opening their first PR
app.on("pull_request.opened", async (context) => {
const config = await utils.getConfig(context);
await greetings.commentOnfirstPR(context, config);
});
// "Greetings" - Congratulate Authors on getting their first PR merged
app.on("pull_request.closed", async (context) => {
const config = await utils.getConfig(context);
await greetings.commentOnfirstPRMerge(context, config);
});
// "Greetings" - Welcome Authors on opening their first Issue
app.on("issues.opened", async (context) => {
const config = await utils.getConfig(context);
await greetings.commentOnfirstIssue(context, config);
});
// "IssueLink" - Update issue links in PRs
app.on(
[
"pull_request.opened",
"pull_request.reopened",
"pull_request.edited",
"pull_request.synchronize",
],
async (context) => {
const config = await utils.getConfig(context);
await issuelink.insertIssueLinkInPrDescription(context, config);
}
);
// "Commit Validator" - validate commit messages for regular expression
app.on(
[
"pull_request.opened",
"pull_request.reopened",
"pull_request.edited",
"pull_request.synchronize",
],
async (context) => {
const config = await utils.getConfig(context);
await titleValidator.verifyTitles(context, config);
}
);
// "Up to date checker" - Check if PR is up to date with master
app.on(
[
"pull_request.opened",
"pull_request.reopened",
"pull_request.edited",
"pull_request.synchronize",
],
async (context) => {
const config = await utils.getConfig(context);
await upToDateChecker.checkUpToDate(context, config);
}
);
};