forked from zebra-lucky/actions-js-getRelease
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (25 loc) · 951 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
const core = require('@actions/core');
const github = require('@actions/github');
async function run() {
try {
const context = github.context;
const octokit = github.getOctokit(process.env.GITHUB_TOKEN);
const { owner, repo } = context.repo;
const tag = core.getInput('tag', { required: true })
.replace('refs/tags/', '');
const getReleaseResponse = await octokit.rest.repos.getReleaseByTag({
owner,
repo,
tag
});
const {
data: { id: releaseId, html_url: htmlUrl, upload_url: uploadUrl, name: name, body: body, draft: draft, prerelease: prerelease, author: author }
} = getReleaseResponse;
console.log(`Got release info: '${releaseId}', '${htmlUrl}', '${uploadUrl}', '${name}', '${draft}', '${prerelease}', '${body}', '${author}'`);
core.setOutput("upload_url", uploadUrl);
} catch (error) {
console.log(error);
core.info(`err: ${error.message}`);
}
}
run();