Skip to content

Instantly share code, notes, and snippets.

@prabirshrestha
Created October 9, 2013 02:25
Show Gist options
  • Save prabirshrestha/6895172 to your computer and use it in GitHub Desktop.
Save prabirshrestha/6895172 to your computer and use it in GitHub Desktop.
sample buildbox shell script
#/bin/bash
# Exits bash immediately if any command fails
set -e
# Will output commands as the run
set -x
# Want to know what ENV varibles Buildbox sets during the build?
env | grep BUILDBOX
# Buildbox will run your builds by default in:
# ~/.buildbox/team-name/project-name
pwd
# Here are some basic setup instructions for checkout out a git repository.
# You have to manage checking out and updating the repo yourself.
# If the git repo doesn't exist in the b
if [ ! -d ".git" ]; then
git clone "$BUILDBOX_REPO" . -q
fi
# Always start with a clean repo
git clean -fd
# Fetch the latest commits from origin, and checkout to the commit being tested
git fetch -q
git checkout -qf "$BUILDBOX_COMMIT"
# nvm - node version manager
[[ -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh
#nvm use 0.10.19
nvm use $(node -e "console.log(require('./package.json').engines.node)")
npm install
if [ "$BUILDBOX_BRANCH" == "dev" ]
then
export NODE_ENV=dev
fi
# Want to do continious delivery? It's easy to only run commands on a paticular branch.
# Here
if [ "$BUILDBOX_BRANCH" != "master" ]
then
echo "Skipping deploy for the $BUILDBOX_BRANCH branch."
exit 0
fi
# Run what ever deploy command you ususally run
# cap deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment