From a4e377d0a298d5c3e5241714f70e3a06a61a7f06 Mon Sep 17 00:00:00 2001 From: Jason Walton Date: Fri, 13 Sep 2019 13:35:26 -0400 Subject: [PATCH 1/2] feat: Put tag name in output named 'tag'. --- README.md | 5 +++-- action.yml | 3 +++ src/main.ts | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a36720dc..71d08b39 100644 --- a/README.md +++ b/README.md @@ -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 @@ -9,4 +10,4 @@ Dead simple: ```yaml steps: - uses: olegtarasov/get-tag@v1 -``` \ No newline at end of file +``` diff --git a/action.yml b/action.yml index b4dc4624..2b18cef5 100644 --- a/action.yml +++ b/action.yml @@ -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' \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 4ebb32d0..435eefc1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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); From a37860022183e0109709659ae1b7ad4a8bcfa3b8 Mon Sep 17 00:00:00 2001 From: Oleg Tarasov Date: Mon, 16 Sep 2019 09:32:32 +0300 Subject: [PATCH 2/2] Built the lib --- lib/main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 633e4622..6060d060 100644 --- a/lib/main.js +++ b/lib/main.js @@ -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) {