-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (37 loc) · 1.27 KB
/
index.js
File metadata and controls
47 lines (37 loc) · 1.27 KB
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
const core = require('@actions/core');
const github = require("@actions/github");
const wait = require('./wait');
// most @actions toolkit packages have async methods
async function run() {
try {
const ms = core.getInput('milliseconds');
core.info(`Waiting ${ms} milliseconds ...`);
core.debug((new Date()).toTimeString()); // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true
await wait(parseInt(ms));
core.info((new Date()).toTimeString());
core.setOutput('time', new Date().toTimeString());
const githubToken = process.env["GITHUB_TOKEN"];
if (!githubToken) {
core.setFailed("GITHUB_TOKEN does not exist.");
return;
}
const context = github.context;
const octokit = github.getOctokit(githubToken);
const { owner, repo } = context.repo;
const labels = ['bug', 'test']
const issueNumber = context.issue.number;
core.info(`Add labels: ${labels} to ${owner}/${repo}#${issueNumber}`);
await octokit.request('POST /repos/{owner}/{repo}/issues/{issue_number}/labels', {
owner: owner,
repo: repo,
issue_number: issueNumber,
labels: [
'bug',
'enhancement'
]
})
} catch (error) {
core.setFailed(error.message);
}
}
run();