From a3b3f4058e3d9ea56cc38f61f2d53b560cc55650 Mon Sep 17 00:00:00 2001 From: Youngduk Suh Date: Sun, 30 Oct 2022 08:12:34 +0900 Subject: [PATCH 1/3] Redirect output to variable --- action.yml | 7 ++++++- entrypoint.sh | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 2b30ae4..b88d37a 100644 --- a/action.yml +++ b/action.yml @@ -8,6 +8,11 @@ inputs: args: description: 'Arguments for the CLI command' required: false + redirect-to: + description: 'Variable name to redirect CLI output' + required: false runs: using: 'docker' - image: 'Dockerfile' \ No newline at end of file + image: 'Dockerfile' + env: + dest: ${{ inputs.redirect-to }} diff --git a/entrypoint.sh b/entrypoint.sh index 77afe3d..6a0e6e5 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -37,4 +37,12 @@ if [ ! -f "$HOME/.kube/config" ]; then fi fi -kubectl $* \ No newline at end of file +if [ -z "$dest" ]; then + kubectl $* +else + output=$(kubectl $*) + echo "::set-output name=$dest::$output" + + # debug only + #echo $output +fi From 06b833eee9f4e532ee3d59e43fb7fd019e9345de Mon Sep 17 00:00:00 2001 From: YD Suh Date: Tue, 1 Nov 2022 10:25:05 +0900 Subject: [PATCH 2/3] add mask for kubectl output --- entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/entrypoint.sh b/entrypoint.sh index 6a0e6e5..f304a6b 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -42,6 +42,7 @@ if [ -z "$dest" ]; then else output=$(kubectl $*) echo "::set-output name=$dest::$output" + echo "::add-mask::$output" # debug only #echo $output From 977919c36f8f15c99404665d8fbecdfeb7d1a2e7 Mon Sep 17 00:00:00 2001 From: YD Suh Date: Tue, 1 Nov 2022 19:19:32 +0900 Subject: [PATCH 3/3] Fix multiline output error --- entrypoint.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index f304a6b..79da000 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -40,10 +40,9 @@ fi if [ -z "$dest" ]; then kubectl $* else - output=$(kubectl $*) - echo "::set-output name=$dest::$output" - echo "::add-mask::$output" - - # debug only - #echo $output + echo "$dest<> $GITHUB_ENV + kubectl $* >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + echo "::add-mask::$dest" fi