-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
42 lines (33 loc) · 952 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
35
36
37
38
39
40
41
42
/** Copyright (c) 2017 Uber Technologies, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const parseTitle = require('./parse-title.js');
module.exports = robot => {
robot.on('pull_request.closed', landed);
async function landed(context) {
const pr = context.payload.pull_request;
if (!pr.merged) {
return;
}
const {github} = context;
const labels = await github.issues.getIssueLabels(context.issue());
const isRelease = labels.data.some(
label => label.name.toLowerCase() === 'release',
);
if (!isRelease) {
return;
}
const {version: tag_name, prerelease} = parseTitle(pr.title);
github.repos.createRelease(
context.repo({
body: tag_name,
tag_name,
prerelease,
name: tag_name,
target_commitish: pr.merge_commit_sha,
}),
);
}
};