-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
main.ts
48 lines (40 loc) · 1.12 KB
/
main.ts
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
43
44
45
46
47
48
import * as github from '@actions/github';
import * as core from '@actions/core';
async function run(): Promise<void> {
try {
const githubToken = core.getInput('github_token', {required: true});
const labels = core.getMultilineInput('labels');
const [owner, repo] = core.getInput('repo').split('/');
const number =
core.getInput('number') === ''
? github.context.issue.number
: parseInt(core.getInput('number'));
if (labels.length === 0) {
return;
}
const client = github.getOctokit(githubToken);
const remaining = [];
for (const label of labels) {
try {
await client.issues.removeLabel({
name: label,
owner,
repo,
issue_number: number
});
} catch (e) {
core.warning(`failed to remove label: ${label}: ${e}`);
remaining.push(label);
}
}
if (remaining.length) {
throw new Error(`failed to remove labels: ${remaining}`);
}
} catch (e) {
core.error(e);
if (core.getInput('fail_on_error') === 'true') {
core.setFailed(e.message);
}
}
}
run();