From e32a76732306c7c8fd6fd654bcd7163d52c97249 Mon Sep 17 00:00:00 2001 From: Andrei Dumitrescu <5057797+andreidmt@users.noreply.github.com> Date: Fri, 2 Apr 2021 11:37:52 +0200 Subject: [PATCH] feat(ci): Set environment variables based on branch --- .circleci/config.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index ac46555..a796617 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -90,6 +90,27 @@ jobs: keys: - tpl-react-{{ .Branch }}-{{ .Revision }} + # In every step, CircleCI uses bash to source BASH_ENV. + # This means that BASH_ENV is automatically loaded and run, + # allowing you to use interpolation and share environment + # variables across run steps. + - run: + name: "tpl-react: Configure env variables based on branch" + command: | + echo 'export VAR1=${GLOBAL_VAR1}' >> ${BASH_ENV} + if [ "${CIRCLE_BRANCH}" == "master" ]; then + echo ' + export VAR2="${MASTER_VAR2}" + export VAR3="${MASTER_VAR3}" + ' >> ${BASH_ENV} + fi + if [ "${CIRCLE_BRANCH}" == "dev" ]; then + echo ' + export VAR2="${DEV_VAR2}" + export VAR3="${DEV_VAR3}" + ' >> ${BASH_ENV} + fi + - run: name: "tpl-react: GitHub release notes, CHANGELOG and package version" command: "npm run release"