Skip to content

Commit

Permalink
Merge pull request #1 from jwalton/master
Browse files Browse the repository at this point in the history
feat: Put tag name in output named 'tag'.
  • Loading branch information
olegtarasov committed Sep 16, 2019
2 parents 174c6ff + a378600 commit 528741c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Get tag name

This simple action gets tag name from commit that triggered the action and puts it into an environment variable GITHUB_TAG_NAME.
This simple action gets tag name from commit that triggered the action and puts it into an environment variable GITHUB_TAG_NAME. It will also export is as an output
named "tag".

## Usage

Expand All @@ -9,4 +10,4 @@ Dead simple:
```yaml
steps:
- uses: olegtarasov/get-tag@v1
```
```
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ author: 'Oleg Tarasov'
runs:
using: 'node12'
main: 'lib/main.js'
outputs:
tag:
description: The tag name.
branding:
icon: 'tag'
color: 'orange'
4 changes: 3 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ function run() {
const ref = github.context.ref;
const tagPath = "refs/tags/";
if (ref && ref.startsWith(tagPath)) {
core.exportVariable("GITHUB_TAG_NAME", ref.substr(tagPath.length, ref.length));
const tag = ref.substr(tagPath.length, ref.length);
core.exportVariable("GITHUB_TAG_NAME", tag);
core.setOutput('tag', tag);
}
}
catch (error) {
Expand Down
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ async function run() {
const ref = github.context.ref
const tagPath = "refs/tags/"
if (ref && ref.startsWith(tagPath)) {
core.exportVariable("GITHUB_TAG_NAME", ref.substr(tagPath.length, ref.length))
const tag = ref.substr(tagPath.length, ref.length);
core.exportVariable("GITHUB_TAG_NAME", tag);
core.setOutput('tag', tag);
}
} catch (error) {
core.setFailed(error.message);
Expand Down

0 comments on commit 528741c

Please sign in to comment.