Skip to content

Commit

Permalink
Fix DEPLOY_ENV in non-production environments
Browse files Browse the repository at this point in the history
  • Loading branch information
David Clark committed Jun 10, 2018
1 parent 6a094da commit 77977e9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions build/set-deploy-env.sh
@@ -0,0 +1,21 @@
# Establish environment variables based on the branch name.
#
# This is an sh script (instead of Node or bash) because it needs to run in the
# top-level process so the environment variables it creates are available to
# all children processes (e.g. `x && y && z`). `npm run` executes in an `sh`
# environment -- so, sh it is.

# `git symbolic-ref HEAD` outputs `refs/head/{your-branch-name}`.
branch=`git symbolic-ref HEAD | sed "s/refs\/heads\/\(.*\)/\1/"`

if [ -z "$DEPLOY_ENV" ]
then
if [ "$branch" = "mb-pages" ]
then
export DEPLOY_ENV=production
else
export DEPLOY_ENV=staging
fi
fi

echo "DEPLOY_ENV set to $DEPLOY_ENV"
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -136,7 +136,7 @@
"start-debug": "run-p build-token watch-dev watch-style-property-editor start-server",
"start-bench": "run-p build-token watch-benchmarks watch-benchmarks-view start-server",
"build-docs": "documentation build --github --format json --config ./docs/documentation.yml --output docs/components/api.json src/index.js",
"build": "run-s build-docs && DEPLOY_ENV=production batfish build # invoked by publisher when publishing docs on the mb-pages branch",
"build": "run-s build-docs && build/set-deploy-env.sh && batfish build # invoked by publisher when publishing docs on the mb-pages branch",
"start-docs": "run-s build-min build-docs && DEPLOY_ENV=local batfish start",
"lint": "eslint --cache --ignore-path .gitignore src test bench docs/pages/example/*.html debug/*.html",
"lint-docs": "documentation lint src/index.js",
Expand Down

0 comments on commit 77977e9

Please sign in to comment.