From 2345285702961fcdac06f4a853ea50795a9fc5af Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 29 Mar 2023 19:20:21 +0200 Subject: [PATCH] ci: allow overriding script inputs from the environment When testing out these scripts on a fork, I realized that it was more convenient to use a single environment variable (e.g., `GITHUB_API_URL=... ci/draft-release.sh`) to change some of the script's input parameters. --- ci/download-workflow-artifacts.sh | 8 ++++---- ci/draft-release.sh | 10 +++++----- ci/get-workflows-for-tag.sh | 8 ++++---- ci/is-workflow-valid.sh | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ci/download-workflow-artifacts.sh b/ci/download-workflow-artifacts.sh index 5b53868..409b484 100755 --- a/ci/download-workflow-artifacts.sh +++ b/ci/download-workflow-artifacts.sh @@ -10,10 +10,10 @@ set -e # # Usage: download-workflow-artifacts.sh -WORKFLOW_RUN_ID=$1 -GITHUB_TOKEN=$2 -GITHUB_API_VERSION=2022-11-28 -GITHUB_API_URL=https://api.github.com/repos/WebAssembly/wasi-sdk +WORKFLOW_RUN_ID=${WORKFLOW_RUN_ID:-$1} +GITHUB_TOKEN=${GITHUB_TOKEN:-$2} +GITHUB_API_VERSION=${GITHUB_API_VERSION:-2022-11-28} +GITHUB_API_URL=${GITHUB_API_URL:-https://api.github.com/repos/WebAssembly/wasi-sdk} TMP_DIR=$(mktemp -d -t wasi-sdk-artifacts.XXXXXXX) if [ -z "${WORKFLOW_RUN_ID}" ] || [ -z "${GITHUB_TOKEN}" ]; then diff --git a/ci/draft-release.sh b/ci/draft-release.sh index 207da97..905ecb9 100755 --- a/ci/draft-release.sh +++ b/ci/draft-release.sh @@ -12,11 +12,11 @@ set -e # # Usage: draft-release.sh -TAG=$1 -ARTIFACTS_DIR=$2 -GITHUB_TOKEN=$3 -GITHUB_API_VERSION=2022-11-28 -GITHUB_API_URL=https://api.github.com/repos/WebAssembly/wasi-sdk +TAG=${TAG:-$1} +ARTIFACTS_DIR=${ARTIFACTS_DIR:-$2} +GITHUB_TOKEN=${GITHUB_TOKEN:-$3} +GITHUB_API_VERSION=${GITHUB_API_VERSION:-2022-11-28} +GITHUB_API_URL=${GITHUB_API_URL:-https://api.github.com/repos/WebAssembly/wasi-sdk} TMP_DIR=$(mktemp -d -t release.sh.XXXXXXX) if [ -z "${TAG}" ] || [ -z "${ARTIFACTS_DIR}" ] || [ -z "${GITHUB_TOKEN}" ]; then diff --git a/ci/get-workflows-for-tag.sh b/ci/get-workflows-for-tag.sh index 1b117cb..8792041 100755 --- a/ci/get-workflows-for-tag.sh +++ b/ci/get-workflows-for-tag.sh @@ -10,10 +10,10 @@ set -e # # Usage: get-workflows-for-tag.sh -TAG=$1 -GITHUB_TOKEN=$2 -GITHUB_API_VERSION=2022-11-28 -GITHUB_API_URL=https://api.github.com/repos/WebAssembly/wasi-sdk +TAG=${TAG:-$1} +GITHUB_TOKEN=${GITHUB_TOKEN:-$2} +GITHUB_API_VERSION=${GITHUB_API_VERSION:-2022-11-28} +GITHUB_API_URL=${GITHUB_API_URL:-https://api.github.com/repos/WebAssembly/wasi-sdk} if [ -z "${TAG}" ] || [ -z "${GITHUB_TOKEN}" ]; then >&2 echo "Missing parameter; exiting..." diff --git a/ci/is-workflow-valid.sh b/ci/is-workflow-valid.sh index b4097f8..a7f0c80 100755 --- a/ci/is-workflow-valid.sh +++ b/ci/is-workflow-valid.sh @@ -13,11 +13,11 @@ set -e # # Usage: is-workflow-valid.sh -TAG=$1 -WORKFLOW_RUN_ID=$2 -GITHUB_TOKEN=$3 -GITHUB_API_VERSION=2022-11-28 -GITHUB_API_URL=https://api.github.com/repos/WebAssembly/wasi-sdk +TAG=${TAG:-$1} +WORKFLOW_RUN_ID=${WORKFLOW_RUN_ID:-$2} +GITHUB_TOKEN=${GITHUB_TOKEN:-$3} +GITHUB_API_VERSION=${GITHUB_API_VERSION:-2022-11-28} +GITHUB_API_URL=${GITHUB_API_URL:-https://api.github.com/repos/WebAssembly/wasi-sdk} if [ -z "${TAG}" ] || [ -z "${WORKFLOW_RUN_ID}" ] || [ -z "${GITHUB_TOKEN}" ]; then >&2 echo "Missing parameter; exiting..."