This repository was archived by the owner on Jul 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathindex.js
More file actions
51 lines (43 loc) · 1.31 KB
/
index.js
File metadata and controls
51 lines (43 loc) · 1.31 KB
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
const debug = require("debug")("probot:pr-triage");
const Sentry = require("@sentry/node");
const PRTriage = require("./lib/pr-triage");
if (process.env.NODE_ENV === "production") {
Sentry.init({
dsn: "https://dce36edab6334112b02122e07b2bc549@sentry.io/1222067",
});
}
function probotPlugin(robot) {
const events = [
"pull_request.opened",
"pull_request.closed",
"pull_request.edited",
"pull_request.synchronize",
"pull_request.reopened",
"pull_request.ready_for_review",
"pull_request_review.submitted",
"pull_request_review.dismissed",
];
robot.on(events, triage);
}
async function triage(context) {
context.log.debug(context.id);
const prTriage = forRepository(context);
const pullRequest = getPullRequest(context);
try {
Sentry.configureScope((scope) => {
scope.setExtra("context_id", context.id);
scope.setExtra("pull_request_html_url", pullRequest.html_url);
});
prTriage.triage(pullRequest);
} catch (e) {
Sentry.captureMessage(e);
}
}
function forRepository(context) {
const config = Object.assign({}, context.repo({ logger: context.log }));
return new PRTriage(context.github, config);
}
function getPullRequest(context) {
return context.payload.pull_request || context.payload.review.pull_request;
}
module.exports = probotPlugin;