From 97ad4fce20ff160d321241f2804a025857c8c756 Mon Sep 17 00:00:00 2001 From: Phu Ngo <12547020+NgoKimPhu@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:05:28 +0000 Subject: [PATCH 1/2] feat: reimplement read-action-input in bash instead of node Signed-off-by: Phu Ngo <12547020+NgoKimPhu@users.noreply.github.com> --- read-action-input | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/read-action-input b/read-action-input index ff36b15..d12ee1c 100755 --- a/read-action-input +++ b/read-action-input @@ -1,13 +1,10 @@ -#!/usr/bin/env node -// helper script for printing kebab-cased env vars. -// e.g., "foo-bar" -> "INPUT_FOO-BAR". -// -// This does not need to be implemented in nodejs, -// but reimplementing this in sh is hard. +#!/usr/bin/env bash +# helper script for printing kebab-cased env vars. +# e.g., "foo-bar" -> "INPUT_FOO-BAR". -const arg = process.argv[2]; // Equates to "$1" in sh -const k = "INPUT_" + arg.toUpperCase(); -const v = process.env[k]; -if ( v !== undefined ) { - console.log(v); -} +arg=INPUT_${1^^} +while IFS= read -r -d '' var; do + [[ $var = "$arg"=* ]] || continue + echo "${var#"${arg}="}" + break +done Date: Sat, 30 Mar 2024 01:37:51 +0700 Subject: [PATCH 2/2] add `set -eu -o pipefail` to read-action-input Signed-off-by: Phu Ngo <12547020+NgoKimPhu@users.noreply.github.com> --- read-action-input | 1 + 1 file changed, 1 insertion(+) diff --git a/read-action-input b/read-action-input index d12ee1c..67c71c2 100755 --- a/read-action-input +++ b/read-action-input @@ -1,6 +1,7 @@ #!/usr/bin/env bash # helper script for printing kebab-cased env vars. # e.g., "foo-bar" -> "INPUT_FOO-BAR". +set -eu -o pipefail arg=INPUT_${1^^} while IFS= read -r -d '' var; do