-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
51 lines (44 loc) · 1.62 KB
/
main.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
43
44
45
46
47
48
49
50
51
const Octokit = require("@octokit/rest");
const core = require('@actions/core');
const github = require('@actions/github');
const labels = [
{ name: "Low risk", color: "3CD616" },
{ name: "Medium risk", color: "FFCE33" },
{ name: "High risk", color: "FF3C33" },
{ name: "Draft", color: "B316D6" }
];
(async() => {
const ibmGitHubToken = core.getInput('gh_ibm_token');
const zenHubToken = core.getInput('zenhub_ibm_apikey');
const newCoGitHubToken = core.getInput('gh_token');
const context = github.context;
core.info('GitHub IBM Token');
core.info(ibmGitHubToken);
core.info('ZenHub IBM Token');
core.info(zenHubToken);
core.info('This GitHub Token');
core.info(newCoGitHubToken);
const newCoOctokit = github.getOctokit(newCoGitHubToken);
core.info("Successfully initialized NewCo GH Client");
await Promise.all(labels.map(async (label) => {
try {
await newCoOctokit.issues.createLabel({
// owner: context.repo.owner,
// repo: context.repo.repo,
...context.repo,
name: label.name,
color: label.color,
});
core.info("Successfully created label", label);
core.info("------------------------------------");
} catch (error) {
core.error(`Failed to create label (${label.name}/${label.color}) with error: ${error}`);
core.info("------------------------------------");
}
}));
core.info('Finished creating labels!');
process.exit(0);
})().catch(error => {
core.error(error);
process.exit(1);
});