Skip to content

Instantly share code, notes, and snippets.

@toolmantim
Last active May 22, 2016 07:02
Show Gist options
  • Save toolmantim/3387071b436e0f573d67 to your computer and use it in GitHub Desktop.
Save toolmantim/3387071b436e0f573d67 to your computer and use it in GitHub Desktop.
An example Buildbox deploy script for automatically deploying branches of a site or application to different subdomains. So you could have always-up-to-date copies of a branches available at http://<branch>.dev.mysite.com/
#!/usr/bin/env bash
# An example Buildbox deploy script for automatically deploying branches of a
# site or application to different subdomains. So you can have an
# always-up-to-date copy of a branch being available at http://branch.dev.mysite.com/
#
# This copies the currently checked out code to /var/www/<branch name>. You'd
# then configure your web server to dynamically map subdomains to /var/www.
#
# You could just as easily push the branch to Heroku or FTP it to a remote server.
#
# Add this to your app as script/deploy_branch (making sure to set it's
# permissions as executable), and then add it as a "Run script" step in your
# Buildbox build pipeline.
#
# If you wanted you could create a script/test script, and build step, which
# could run some quick tests before the deploy step, just to make sure
# everything is AOK.
#
# You can find webserver vhost configurations here:
#
# * Apache: http://httpd.apache.org/docs/2.4/rewrite/vhosts.html
# * Nginx: http://nginx.org/en/docs/http/server_names.html#regex_names
# Exit immediately if any command fails
set -e
BRANCH_DEPLOY_DIR="/var/www/$BUILDBOX_BRANCH"
echo "--- Copying to $BRANCH_DEPLOY_DIR"
mkdir -p $BRANCH_DEPLOY_DIR
cp -r . $BRANCH_DEPLOY_DIR
echo "--- Deploying site"
# Here you could restart your web server or application, perform database
# operations, etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment