From f16bf5db358e7c56e4695075f7a904632a275046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesus=20Nu=C3=B1ez?= Date: Sat, 9 May 2026 12:54:08 -0400 Subject: [PATCH] fix(action): read INPUT_* env vars via printenv to handle dashes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The GitHub Actions runner forwards inputs as `INPUT_` env vars with dashes preserved verbatim — `plan-file` becomes `INPUT_PLAN-FILE`, not `INPUT_PLAN_FILE` — because only spaces are converted to underscores. POSIX parameter expansion can't reference names with `-` (the dash is the default-value operator), so the previous reads of `${INPUT_PLAN_FILE}` always saw an empty string and the entrypoint exited with "plan-file input is required" before anything else ran. Caught by the in-repo self-test workflow added on this branch. Co-Authored-By: Claude Opus 4.7 (1M context) --- entrypoint.sh | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index de60944..c79b248 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,12 +5,31 @@ # `oracle pr-check` flags, then exec's the binary so its exit code is the # Action's exit code (1=input, 2=pricing, 3=output, 4=github). # +# GitHub keeps dashes verbatim in input env var names (`plan-file` → +# `INPUT_PLAN-FILE`); only spaces are converted to underscores. POSIX +# parameter expansion can't reference names containing `-` because `-` +# is the default-value operator inside `${...}`, so we go through +# `printenv` instead. busybox's `printenv` (alpine) supports this. +# # POSIX-only — no bashisms — because the alpine base ships /bin/sh as # busybox ash. Run shellcheck under -s sh to catch regressions. set -eu +# `printenv NAME` exits non-zero when NAME is unset; `|| true` keeps the +# script alive under `set -e` and the captured stdout is just empty. +input() { + printenv "INPUT_$(echo "$1" | tr '[:lower:]' '[:upper:]')" || true +} + +PLAN_FILE=$(input plan-file) +REGION=$(input region) +OUTPUT_FILE=$(input output-file) +MARKER=$(input marker) +NO_LLM=$(input no-llm) +GITHUB_TOKEN_INPUT=$(input github-token) + # --- Required input ------------------------------------------------------- -if [ -z "${INPUT_PLAN_FILE:-}" ]; then +if [ -z "${PLAN_FILE}" ]; then echo "::error::plan-file input is required" >&2 exit 1 fi @@ -19,16 +38,16 @@ fi # `set -- ...` rewrites positional parameters; each `set -- "$@" ...` line # appends to the existing argv. This is the POSIX-portable way to build # a list when arrays aren't available. -set -- --plan-file="${INPUT_PLAN_FILE}" -set -- "$@" --region="${INPUT_REGION:-us-east-2}" -set -- "$@" --marker="${INPUT_MARKER:-cloudoracle-pr-v1}" +set -- --plan-file="${PLAN_FILE}" +set -- "$@" --region="${REGION:-us-east-2}" +set -- "$@" --marker="${MARKER:-cloudoracle-pr-v1}" -if [ "${INPUT_NO_LLM:-false}" = "true" ]; then +if [ "${NO_LLM:-false}" = "true" ]; then set -- "$@" --no-llm fi -if [ -n "${INPUT_OUTPUT_FILE:-}" ]; then - set -- "$@" --output="${INPUT_OUTPUT_FILE}" +if [ -n "${OUTPUT_FILE}" ]; then + set -- "$@" --output="${OUTPUT_FILE}" fi # --- Auto-post on pull_request[_target] events --------------------------- @@ -49,8 +68,8 @@ if [ "$event" = "pull_request" ] || [ "$event" = "pull_request_target" ]; then set -- "$@" --post set -- "$@" --repo="${GITHUB_REPOSITORY}" set -- "$@" --pr="${PR_NUMBER}" - if [ -n "${INPUT_GITHUB_TOKEN:-}" ]; then - set -- "$@" --token="${INPUT_GITHUB_TOKEN}" + if [ -n "${GITHUB_TOKEN_INPUT}" ]; then + set -- "$@" --token="${GITHUB_TOKEN_INPUT}" fi else echo "::warning::Could not extract PR number from GITHUB_REF=${GITHUB_REF:-}; rendering only, not posting." >&2