From 36b1991b4417ae7292495e884d539a572f31f6c0 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Mon, 31 Jul 2023 20:36:14 -0230 Subject: [PATCH] Fix `prep-deps` CI step (#20312) The CI job `prep-deps` was broken in #20096 for forks and non-PR builds (e.g. the `develop` branch builds). Non-PR builds were broken because of the `set -u` flag, which complained about a PR-specific environment variable being unset. Fork builds were broken because the draft check relied upon secrets (which aren't included in CI runs on forks). The script is now tolerant of missing environment variables, and skips the draft check for forks. --- .circleci/scripts/install-dependencies.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.circleci/scripts/install-dependencies.sh b/.circleci/scripts/install-dependencies.sh index 78c68c549..35b7a690f 100755 --- a/.circleci/scripts/install-dependencies.sh +++ b/.circleci/scripts/install-dependencies.sh @@ -1,15 +1,17 @@ #!/usr/bin/env bash set -e -set -u set -o pipefail -PR_NUMBER="${CIRCLE_PULL_REQUEST##*/}" -if [ -n "$PR_NUMBER" ] +IS_NON_FORK_DRAFT='false' + +if [[ -n $CIRCLE_PULL_REQUEST ]] && gh auth status then - IS_DRAFT="$(gh pr view --json isDraft --jq '.isDraft' "$PR_NUMBER")" -else - IS_DRAFT='false' + PR_NUMBER="${CIRCLE_PULL_REQUEST##*/}" + if [ -n "$PR_NUMBER" ] + then + IS_NON_FORK_DRAFT="$(gh pr view --json isDraft --jq '.isDraft' "$PR_NUMBER")" + fi fi # Build query to see whether there are any "preview-like" packages in the manifest @@ -29,7 +31,7 @@ else HAS_PREVIEW_BUILDS='false' fi -if [[ $IS_DRAFT == 'true' && $HAS_PREVIEW_BUILDS == 'true' ]] +if [[ $IS_NON_FORK_DRAFT == 'true' && $HAS_PREVIEW_BUILDS == 'true' ]] then # Use GitHub registry on draft PRs, allowing the use of preview builds echo "Installing with preview builds"