forked from dawidd6/action-get-tag
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
26 lines (21 loc) · 584 Bytes
/
main.js
File metadata and controls
26 lines (21 loc) · 584 Bytes
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
const core = require("@actions/core")
async function main() {
try {
const ref = process.env.GITHUB_REF
const numbers_only = process.env.INPUT_NUMBERS_ONLY
if(!ref)
throw "GITHUB_REF is not defined"
if(!ref.startsWith("refs/tags/"))
throw `Not a tag ref (${ref})`
let tag = ref.replace(/^refs\/tags\//, "")
if(numbers_only === "true" && tag.startsWith("v"))
tag = tag.replace(/^v/, "")
core.info(`ref=${ref}`)
core.info(`tag=${tag}`)
core.setOutput("tag", tag);
}
catch (error) {
core.setFailed(error);
}
}
main()