Skip to content

Instantly share code, notes, and snippets.

@hipsterjazzbo
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hipsterjazzbo/a1af5434cc50a7493187 to your computer and use it in GitHub Desktop.
Save hipsterjazzbo/a1af5434cc50a7493187 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Fergus Staging Deploy Script
# Update git to staging
cd /var/www/fergus_internal_demo;
#!/bin/bash
function bgtext {
echo -e $(tput setab 24)" $1"$(tput sgr0);
}
#branch_to_deploy
instance_name="fergus_internal_demo Site";
# get branch from argument
if [ "$#" -eq 1 ]
then
branch_name=$1
else
bgtext "Please specify a branch. Eg. beta"
exit
fi
bgtext "Deploy branch $branch_name to $instance_name ? [y/N]"
read -r -p "" response
case $response in
[yY][eE][sS]|[yY])
echo "deploying branch $branch_name to $instance_name";
;;
*)
bgtext "OK. Exiting"
exit
;;
esac
#Get previous hash
prev_commit=$(git rev-parse --verify HEAD) # hash
/usr/bin/git checkout $branch_name;
/usr/bin/git fetch github $branch_name;
/usr/bin/git reset --hard FETCH_HEAD;
# Check if a composer.json file is present and update if neccessary
if [ -f composer.json ]; then
# Detect composer binary
if which composer >/dev/null; then
composer='composer'
elif which composer.phar >/dev/null; then
composer='composer.phar'
else
# Install composer
curl -s http://getcomposer.org/installer | php >/dev/null
composer='php composer.phar'
fi
# Install or update packages specified in the lock file
$composer install
fi
# Clear Cache
php /var/www/fergus_internal_demo/index.php ext clear_cache
# Get last commit
commit_hash=$(git rev-parse --verify HEAD) # hash \n date
commit_description=$(git log --pretty=format:"%s" $prev_commit..HEAD)
# Send deployment to new relic
# curl -H "x-api-key:6c99bf8932ce4146eabcba054fabd38e16d70dd3cc70c01" -d "deployment[application_id]=1786013" -d "deployment[description]=Updated via deploy script" -d "deployment[revision]=$commit_hash" -d "deployment[changelog]=$commit_description" -d "deployment[user]=Jordan Clist" https://rpm.newrelic.com/deployments.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment