-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (37 loc) · 1.41 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
require ('newrelic');
const createScheduler = require('probot-scheduler');
const apiForSheetsModule = require('./lib/apiForSheets');
const checkMergeConflictsModule = require('./lib/checkMergeConflicts');
const whitelistedAccounts = (
(process.env.WHITELISTED_ACCOUNTS || '').toLowerCase().split(','));
var pullRequestAuthor;
module.exports = (robot) => {
scheduler = createScheduler(robot, {
delay: !process.env.DISABLE_DELAY,
interval: 60 * 60 * 1000 // 1 hour
});
robot.on('issue_comment.created', async context => {
if (
whitelistedAccounts.includes(context.repo().owner.toLowerCase()) &&
context.isBot === false) {
const userName = context.payload.comment.user.login;
if (pullRequestAuthor === userName) {
apiForSheetsModule.apiForSheets(userName, context, false);
}
}
});
robot.on('pull_request.opened', async context => {
if (
whitelistedAccounts.includes(context.repo().owner.toLowerCase()) &&
context.isBot === false) {
const userName = context.payload.pull_request.user.login;
pullRequestAuthor = userName;
apiForSheetsModule.apiForSheets(userName, context, true);
}
});
robot.on('schedule.repository', async context => {
if (whitelistedAccounts.includes(context.repo().owner.toLowerCase())) {
await checkMergeConflictsModule.checkMergeConflicts(context);
}
});
};