Skip to content

Commit

Permalink
projects without staging env fallback to prod (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
rioam2 committed Oct 11, 2019
1 parent 396444c commit 3f0313b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"preview:staging": "cross-env NODE_ENV=production yarn loadenv ./scripts/preview.sh",
"setup": "./scripts/setup.js",
"test": "yarn test:unit && yarn test:cypress",
"test:cypress": "start-server-and-test 'yarn preview:staging > /dev/null' 3000 'cypress run'",
"test:cypress": "yarn loadenv yarn start-server-and-test '[ -z %STATIC_STAGE_PROJECT ] && yarn preview:production > /dev/null || yarn preview:staging > /dev/null' 3000 'cypress run'",
"test:cypress:watch": "start-server-and-test 'yarn dev > /dev/null' 3000 'cypress open'",
"test:unit": "mocha ./**/*.unit.test.ts",
"test:unit:watch": "yarn test:unit --watch",
Expand Down
1 change: 1 addition & 0 deletions scripts/loadenv.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const { exec } = require('child_process');
const mergedEnv = { ...dotenv.parsed, ...process.env };
const command = process.argv
.slice(2)
.map((arg) => (arg.includes(' ') && `'${arg}'`) || arg)
.join(' ')
.replace(/\%\S+/g, (match) => `"${mergedEnv[match.slice(1)] || ''}"`);

Expand Down
16 changes: 9 additions & 7 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

set -e

if [[ $TRAVIS_SECURE_ENV_VARS == 'true' ]]; then
yarn test
# Continuous Deployment for staging/production
if [[ $TRAVIS_BRANCH == 'master' ]]; then
if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then
yarn test

# Continuous Deployment for staging/production
if [[ $TRAVIS_BRANCH == 'master' ]]; then
if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then
if [[ ! -z $STATIC_PROD_PROJECT ]] && [[ ! -z $STATIC_DEPLOY_KEY ]]; then
# If tests passed on master and not a PR, deploy to production
yarn deploy:production
wget "https://$STATIC_PROD_PROJECT.web.app" -O /dev/null
else
fi
else
if [[ ! -z $STATIC_STAGE_PROJECT ]] && [[ ! -z $STATIC_DEPLOY_KEY ]]; then
# If tests passed on master for PR, deploy to staging
yarn deploy:staging
wget "https://$STATIC_STAGE_PROJECT.web.app" -O /dev/null
Expand Down

0 comments on commit 3f0313b

Please sign in to comment.