Skip to content

Commit

Permalink
ci: allow overriding script inputs from the environment
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
abrown committed Apr 6, 2023
1 parent 4f678be commit 2345285
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions ci/download-workflow-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ set -e
#
# Usage: download-workflow-artifacts.sh <workflow run ID> <token>

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
Expand Down
10 changes: 5 additions & 5 deletions ci/draft-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ set -e
#
# Usage: draft-release.sh <release tag> <artifacts dir> <token>

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
Expand Down
8 changes: 4 additions & 4 deletions ci/get-workflows-for-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ set -e
#
# Usage: get-workflows-for-tag.sh <tag> <token>

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..."
Expand Down
10 changes: 5 additions & 5 deletions ci/is-workflow-valid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ set -e
#
# Usage: is-workflow-valid.sh <release tag> <workflow run ID> <token>

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..."
Expand Down

0 comments on commit 2345285

Please sign in to comment.