From 316615d33d3591fa3b7f9af29d331bbc8fb63840 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Wed, 16 Nov 2022 22:07:46 -0330 Subject: [PATCH] Support GitHub registry for draft PRs --- .circleci/config.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index f9decf82922c..9abc2c155539 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,6 +14,9 @@ executors: docker: - image: koalaman/shellcheck-alpine@sha256:dfaf08fab58c158549d3be64fb101c626abc5f16f341b569092577ae207db199 +orbs: + gh: circleci/github-cli@2.0 + workflows: test_and_release: jobs: @@ -209,6 +212,27 @@ jobs: - checkout - restore_cache: key: dependency-cache-v1-{{ checksum "yarn.lock" }} + - gh/install + - run: + name: Set IS_DRAFT environment variable + command: | + PR_NUMBER="${CIRCLE_PULL_REQUEST##*/}" + if [ -n "$PR_NUMBER" ] + then + echo "IS_DRAFT=$(gh pr view --json isDraft --jq '.isDraft' "$PR_NUMBER")" >> "$BASH_ENV" + source "$BASH_ENV" + else + echo "Not a PR; skipping" + fi + - run: + name: Setup registry config for using package previews on draft PRs + command: | + if [[ $IS_DRAFT == 'true' ]] + then + printf '%s\n\n%s' '@metamask:registry=https://npm.pkg.github.com' "//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGE_READ_TOKEN}" > .npmrc + else + echo "Not draft; skipping GitHub registry setup" + fi - run: name: Install deps command: |