Created
October 30, 2013 07:53
-
-
Save sinegar/7228687 to your computer and use it in GitHub Desktop.
Build script for buildbox.io which checkout from a private bitbucket repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Exits bash immediately if any command fails | |
set -e | |
REMOTE_KEY=~/.ssh/builderkey | |
# 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/account-name/project-name | |
# pwd | |
## for testing uncomment the line to refresh ssh key | |
# rm $REMOTE_KEY* | |
# generate ssh key if does not exist | |
# set as default key | |
if [ ! -f "$REMOTE_KEY" ]; then | |
ssh-keygen -q -t rsa -f $REMOTE_KEY -N "" | |
echo "IdentityFile $REMOTE_KEY" >> ~/.ssh/config | |
fi | |
# print out current public key - usefull to copy and add to bitbucket | |
ssh-keygen -q -y -f $REMOTE_KEY | |
# add bitbucket.org to ssh known_hosts | |
# TODO replace hardcoded [email protected] with parsing $BUILDBOX_REPO | |
ssh -T -o StrictHostKeyChecking=no [email protected] | |
# 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 | |
git checkout -f "$BUILDBOX_COMMIT" | |
# added pull because 'git checkout -f master' didn't get latest changes | |
git pull | |
# Here are some basic instructions on how to run tests on a Ruby on Rails project | |
# with rspec. You can change these commands to be what ever you like. | |
# bundle install | |
# bundle exec rake db:schema:load | |
# bundle exec rspec | |
# npm and grunt dependency: https://github.com/buildboxhq/buildbox-heroku/pull/2 | |
npm install | |
grunt | |
# 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