forked from buildsville/add-remove-label
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (37 loc) · 1.21 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
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
exports.__esModule = true;
var core = require("@actions/core");
var github = require("@actions/github");
var token = core.getInput("token");
var type = core.getInput("type");
var label = core.getInput("label");
function editLabel() {
var client = new github.GitHub(token);
var context = github.context;
var pr = context.payload.pull_request;
if (!pr) {
return;
}
if (type == "add") {
client.issues.addLabels(__assign(__assign({}, context.repo), { issue_number: pr.number, labels: [label] }))["catch"](function (e) {
console.log(e.message);
});
}
if (type == "remove") {
client.issues.removeLabel(__assign(__assign({}, context.repo), { issue_number: pr.number, name: label }))["catch"](function (e) {
console.log(e.message);
});
}
}
editLabel();