Skip to content

Commit

Permalink
Merge pull request #22 from NgoKimPhu/ft/remove-node-dependency
Browse files Browse the repository at this point in the history
feat: reimplement read-action-input in bash instead of node
  • Loading branch information
AkihiroSuda authored Mar 30, 2024
2 parents e2c919a + c6c954a commit fef4b80
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions read-action-input
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/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".
set -eu -o pipefail

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 </proc/self/environ

0 comments on commit fef4b80

Please sign in to comment.