generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (21 loc) · 928 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
const github = require("@actions/github");
const core = require("@actions/core");
// most @actions toolkit packages have async methods
async function run() {
try {
const token = core.getInput("github_token");
const octokit = github.getOctokit(token);
const context = github.context;
const { owner, repo } = context.repo;
const sha = core.getInput("sha") || context.sha;
const tag = core.getInput("tag", { required: true });
const message = core.getInput("message", { required: true });
const { data: tagResponse } = await octokit.rest.git.createTag({ owner, repo, tag, message, object: sha, sha, type: "commit" });
const refResponse = await octokit.rest.git.createRef({ owner, repo, ref: `refs/tags/${tagResponse.tag}`, sha: tagResponse.sha });
core.setOutput("ref", refResponse.data.ref);
} catch (error) {
core.info(error);
core.setFailed(error.message);
}
}
run();