From cd38cd76fd2f1897e4a59ff600e8fc3ef8f9ddaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Thu, 19 Dec 2024 23:12:40 +0100 Subject: [PATCH] fix(sh): ${VAR:-val} and ${VAR-val} are different Who would've thought? `:` means or empty, so: ```sh VAR= echo "${VAR-default}" # prints 'default' VAR='' echo "${VAR-default}" # prints '' VAR='' echo "${VAR:-default}" # prints 'default' ``` ;-; nothing wants to work --- comment_on_pr.sh | 8 ++++---- create-report.sh | 2 +- retrieve-old-report.sh | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/comment_on_pr.sh b/comment_on_pr.sh index 58b04de..8b394ad 100755 --- a/comment_on_pr.sh +++ b/comment_on_pr.sh @@ -2,7 +2,7 @@ set -eu -util_path="${GITHUB_ACTION_PATH-.}/utils.sh" +util_path="${GITHUB_ACTION_PATH:-.}/utils.sh" # shellcheck source=utils.sh . "${util_path}" @@ -50,7 +50,7 @@ markdown_from_report() { cat <<-"EOF" - `[NAR] Size Change`: the amount changed compared to the main branch EOF - compare=$(jq --slurp --from-file "${GITHUB_ACTION_PATH-.}/compare.jq" "$1" "$2") + compare=$(jq --slurp --from-file "${GITHUB_ACTION_PATH:-.}/compare.jq" "$1" "$2") if echo "$compare" | has_elements 'nixosConfigurations'; then cat <<-"EOF" # NixOS Configurations @@ -96,14 +96,14 @@ markdown_from_report() { } # Test outside CI -if [ "${CI-false}" != 'true' ]; then +if [ "${CI:-false}" != 'true' ]; then markdown_from_report "$@" exit 0 fi log 'Determine head_ref' # For push & tag events it'll bet GITHUB_REF_NAME, for pull_request events it'll be GITHUB_HEAD_REF -head_ref=${GITHUB_REF_NAME-$GITHUB_HEAD_REF} +head_ref=${GITHUB_REF_NAME:-$GITHUB_HEAD_REF} log "Get PR number for $head_ref" prs=$(curl -X 'GET' \ diff --git a/create-report.sh b/create-report.sh index 0452793..1a8a15d 100755 --- a/create-report.sh +++ b/create-report.sh @@ -2,7 +2,7 @@ set -eu -util_path="${GITHUB_ACTION_PATH-.}/utils.sh" +util_path="${GITHUB_ACTION_PATH:-.}/utils.sh" # shellcheck source=utils.sh . "${util_path}" diff --git a/retrieve-old-report.sh b/retrieve-old-report.sh index 694e5ec..0d748b1 100755 --- a/retrieve-old-report.sh +++ b/retrieve-old-report.sh @@ -38,7 +38,7 @@ has_report() { } # If a base branch is not provided, use the default branch -base_branch=${BASE_BRANCH-$(default_branch)} +base_branch=${BASE_BRANCH:-$(default_branch)} if [ "$(in_private_repo)" != 'true' ] && [ "$JOB_NAME" ]; then url=$(base_report_url "$base_branch")