Skip to content

Commit

Permalink
fix(build): issues/97 branching and integration
Browse files Browse the repository at this point in the history
* expanded ci build stages
* leverage stage names to determine beta path deployment
  • Loading branch information
cdcabrera committed Sep 10, 2019
1 parent 62e65af commit 7922276
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 17 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ jobs:
- before_script: yarn global add codecov
script: yarn test:ci
after_success: codecov
- stage: Deploy
- stage: Beta Deploy
script: yarn build && curl -sSL https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master/src/bootstrap.sh | bash -s
- stage: Stable Deploy
script: yarn build && curl -sSL https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master/src/bootstrap.sh | bash -s
env:
global:
- REPO="git@github.com:RedHatInsights/curiosity-frontend-build"
- REPO_DIR="curiosity-frontend-build"
- BRANCH=${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}
- BUILD_STAGE="${TRAVIS_BUILD_STAGE_NAME}"
- NODE_OPTIONS="--max-old-space-size=4096 --max_old_space_size=4096"
- APP_BUILD_DIR="build"
49 changes: 38 additions & 11 deletions .travis/custom_release.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,56 @@
#!/bin/bash
#
#
# main()
# CI/Dev beta release for "ci-beta" and "qa-beta" branches, based on deploy stage name
#
releaseDev()
{
set -e
set -x

if [ "${TRAVIS_BRANCH}" = "ci" ]; then
echo "PUSHING ci-beta"
if [[ "${TRAVIS_BRANCH}" = "ci" ]] && [[ $TRAVIS_BUILD_STAGE_NAME == *"Beta"* ]]; then
printf "${YELLOW}PUSHING ci-beta${NOCOLOR}\n"
rm -rf ./build/.git
.travis/release.sh "ci-beta"
printf "${GREEN}COMPLETED ci-beta${NOCOLOR}\n"

echo "PUSHING qa-beta"
printf "${YELLOW}PUSHING qa-beta${NOCOLOR}\n"
rm -rf ./build/.git
.travis/release.sh "qa-beta"
printf "${GREEN}COMPLETED qa-beta${NOCOLOR}\n"
fi

if [ "${TRAVIS_BRANCH}" = "master" ]; then
echo "PUSHING prod-beta"
}
#
#
# Prod release for "master" branch based on deploy stage name.
#
releaseProd()
{
if [[ "${TRAVIS_BRANCH}" = "master" ]] && [[ $TRAVIS_BUILD_STAGE_NAME == *"Beta"* ]]; then
printf "${YELLOW}PUSHING prod-beta${NOCOLOR}\n"
rm -rf ./build/.git
.travis/release.sh "prod-beta"
printf "${GREEN}COMPLETED prod-beta${NOCOLOR}\n"
fi

echo "PUSHING prod-stable"
if [[ "${TRAVIS_BRANCH}" = "master" ]] && [[ $TRAVIS_BUILD_STAGE_NAME != *"Beta"* ]]; then
printf "${YELLOW}PUSHING prod-stable${NOCOLOR}\n"
rm -rf ./build/.git
.travis/release.sh "prod-stable"
printf "${GREEN}COMPLETED prod-stable${NOCOLOR}\n"
fi
}
#
#
# main()
#
{
set -e
set -x

BLUE="\e[34m"
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
NOCOLOR="\e[39m"

releaseDev
releaseProd
}
17 changes: 12 additions & 5 deletions scripts/pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
deployPaths()
{
local CI_BRANCH=$1
local CI_BUILD_STAGE=$2

DEPLOY_PATH_PREFIX=""

if [[ $CI_BRANCH == *"beta"* ]] || [[ $CI_BRANCH == *"master"* ]]; then
if [[ $CI_BUILD_STAGE == *"Beta"* ]]; then
DEPLOY_PATH_PREFIX=/beta
fi

echo UI_DEPLOY_PATH_PREFIX="$DEPLOY_PATH_PREFIX" >> ./.env.production.local

echo "Deploy config for branch \"${CI_BRANCH}\"..."
echo "Deploy path prefix ... UI_DEPLOY_PATH_PREFIX=$DEPLOY_PATH_PREFIX"
echo "\"${CI_BUILD_STAGE}\" build stage config for branch \"${CI_BRANCH}\"..."
printf "Deploy path prefix ... ${GREEN}UI_DEPLOY_PATH_PREFIX=$DEPLOY_PATH_PREFIX${NOCOLOR}\n"
}
#
#
Expand All @@ -25,7 +26,7 @@ deployPaths()
version()
{
UI_VERSION="$(node -p 'require(`./package.json`).version').$(git rev-parse --short HEAD)"
echo "Version... UI_VERSION=$UI_VERSION"
printf "Version... ${GREEN}UI_VERSION=$UI_VERSION${NOCOLOR}\n"
echo UI_VERSION="$UI_VERSION" >> ./.env.production.local
}
#
Expand All @@ -44,9 +45,15 @@ clean()
# main()
#
{
BLUE="\e[34m"
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
NOCOLOR="\e[39m"

clean
version

# see .travis.yml globals
deployPaths ${BRANCH:-local}
deployPaths "${BRANCH:-local}" "${BUILD_STAGE:-Local Deploy}"
}

0 comments on commit 7922276

Please sign in to comment.