Created
October 23, 2014 14:34
-
-
Save a-fro/b24b098f1a8877ebe15c to your computer and use it in GitHub Desktop.
Acquia Deploy script
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 | |
REPO_BASE='[project foldername here (the folder above docroot)]' | |
# check running from the repository base | |
CURRENT_DIR=${PWD##*/} | |
if [ ! "$CURRENT_DIR" = $REPO_BASE ]; then | |
echo 'Please be sure that you are running this command from the root of the repo.' | |
exit 2 | |
fi | |
# Figure out which environment to deploy to | |
while getopts "e:" var; do | |
case $var in | |
e) ENV="${OPTARG}";; | |
esac | |
done | |
# Set the ENV to dev if 'e' wasn't passed as an argument | |
if [ "${#ENV}" -eq "0" ]; then | |
ENV='dev' | |
fi | |
if [ "$ENV" = "dev" ] || [ "$ENV" = "test" ]; then | |
# Set the css_path and livedev path | |
CSS_PATH='docroot/sites/all/themes/theme_name/css/' | |
# Replace [user@devcloud.host] with your real Acquia Cloud SSH host | |
# Available in the AC interface under the "Users and keys" tab | |
ACQUIA_LIVEDEV='[user@devcloud.host]:~/$ENV/livedev/' | |
# Get the branch name | |
BRANCH_NAME="$(git symbolic-ref HEAD 2>/dev/null)" || | |
BRANCH_NAME="detached" # detached HEAD | |
BRANCH_NAME=${BRANCH_NAME##refs/heads/} | |
echo "Pushing $BRANCH_NAME to acquia cloud $ENV" | |
git push -f ac $BRANCH_NAME # This assumes you have a git remote called "ac" that points to Acquia | |
echo "Compiling css" | |
compass compile | |
# Upload to server | |
echo "Uploading styles to server" | |
scp -r $CSS_PATH "$ACQUIA_LIVEDEV~/$ENV/livedev/$CSS_PATH": | |
# Pull the updates from the branch to livedev and clear cache | |
echo "Deploying $BRANCH_NAME to livedev on Acquia" | |
ssh $ACQUIA_LIVEDEV "git checkout .; git pull; git checkout $BRANCH_NAME; cd docroot; exit;" | |
echo "Clearing cache on $ENV" | |
cd docroot | |
drush [DRUSH_ALIAS].$ENV cc all -y | |
echo "Deployment complete" | |
if [ "$ENV" = "dev" ]; then | |
read -r -p "Would you like to rebuild the site? [y/N] " response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
BIN_DIR=`dirname $0` | |
source $BIN_DIR/acquia-reinstall | |
fi | |
fi | |
exit | |
fi | |
# If not dev or test, throw an error | |
echo 'Error: the deploy script is for the Acquia dev and test environments' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment