-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpr-editor.js
38 lines (32 loc) · 1.29 KB
/
pr-editor.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
module.exports = function (data, process) {
var PAYLOAD = data.payload,
ACCESS_TOKEN = data.access_token,
GET = data.parameters;
if (PAYLOAD.action === 'opened') {
request.get(GET.template, function templateReceived(err, httpResponse, body) {
var options = {
url: PAYLOAD.pull_request.url,
headers: {
'Content-Type': 'application/json',
'User-Agent': 'pr-editor',
'Authorization': 'token ' + ACCESS_TOKEN
},
json: {
"body": PAYLOAD.pull_request.body + "\n" + body + "\n-----\n" + "Template automatically appended by githook-pr-editor."
}
};
console.log(options);
request.post(options, function templatePosted(err, httpResponse, body) {
if (err) {
process.fail('Could not send POST request: ' + err);
}
else {
process.succeed('Template POST message successful. Response:' + body);
}
});
});
}
else {
process.succeed(PAYLOAD.action + ' (payload action) was not "opened", so there was nothing to do here.');
}
};