-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (28 loc) · 943 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
34
'use strict';
const { getProjectsForTopicAndOrg } = require('./project');
const { pushProjectsToSlack } = require('./slack');
const apiRequest = (event, context, callback) => {
getProjectsForTopicAndOrg(process.env.GITHUB_TOPIC, process.env.GITHUB_ORG)
.then(pullRequests => callback(null, pullRequests));
};
exports.handler = (event, context, callback) => {
if (
!process.env.GITHUB_API_KEY
|| !process.env.GITHUB_ORG
|| !process.env.GITHUB_TOPIC
|| !process.env.SLACK_ENDPOINT
) {
process.stdout.write(`
Please include the following environment variables to execute this script:
- GITHUB_API_KEY
- GITHUB_ORG
- GITHUB_TOPIC
- SLACK_ENDPOINT
`);
process.exit(1);
}
if (event && event.apiRequest) {
return apiRequest(event, context, callback);
}
apiRequest(event, context, (error, pullRequests) => pushProjectsToSlack(pullRequests));
};