#!/usr/bin/env bash
# eval output of this file to get appropriate env variables e.g. eval "$(./env_vars.sh)"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
RED='\033[0;31m'
NC='\033[0m'

if [[ "$CIRCLECI" ]]; then
    # on circle ci determine env variables based on branch or in case of PR
    # what branch the PR is pointing to
    if [[ "$CIRCLE_PULL_REQUEST" ]]; then
        BRANCH=$(curl "${CIRCLE_PULL_REQUEST}" | grep -oE 'cBioPortal/cbioportal-frontend:[^"]*' | cut -d: -f2)
    else
        BRANCH=$CIRCLE_BRANCH
    fi
    cat $SCRIPT_DIR/../env/${BRANCH}.sh
elif [[ "$BRANCH_ENV" ]]; then
    cat $SCRIPT_DIR/../env/${BRANCH_ENV}.sh

    # override with custom exports if they exist
    if [[ -f ${SCRIPT_DIR}/env/custom.sh ]]; then
        cat ${SCRIPT_DIR}/env/custom.sh
    fi
else
    echo -e "${RED}No desired BRANCH_ENV variable set${NC}"
    echo -e "${RED}set with e.g. export BRANCH_ENV=master${NC}"
    echo -e "${RED}or export BRANCH_ENV=rc${NC}"
    exit 1
fi

#!/usr/bin/env bash
# eval output of this file to get appropriate env variables e.g. eval "$(./env_vars.sh)"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
RED='\033[0;31m'
NC='\033[0m'

if [[ "$CIRCLECI" ]]; then
    # on circle ci determine env variables based on branch or in case of PR
    # what branch the PR is pointing to
    if [[ "$CIRCLE_PULL_REQUEST" ]]; then
        BRANCH=$(curl "${CIRCLE_PULL_REQUEST}" | grep -oE 'cBioPortal/cbioportal-frontend:[^"]*' | cut -d: -f2 | head -1)
    else
        BRANCH=$CIRCLE_BRANCH
    fi
    cat $SCRIPT_DIR/../env/${BRANCH}.sh
elif [[ "$BRANCH_ENV" ]]; then
    cat $SCRIPT_DIR/../env/${BRANCH_ENV}.sh

    # override with custom exports if they exist
    if [[ -f ${SCRIPT_DIR}/env/custom.sh ]]; then
        cat ${SCRIPT_DIR}/env/custom.sh
    fi
else
    echo -e "${RED}No desired BRANCH_ENV variable set${NC}"
    echo -e "${RED}set with e.g. export BRANCH_ENV=master${NC}"
    echo -e "${RED}or export BRANCH_ENV=rc${NC}"
    exit 1
fi

Fix base parsing of github pull request on circle
Fix base parsing of github pull request on circle

There was error when parsing the base from the github PR. This fixes the corner
case when the base was changed inside the PR.


Former-commit-id: 6a8d0a97ada41d8cd7c9a4fed6f3a22da1972d48