Created
March 31, 2016 02:09
-
-
Save egoens/e6781a2c55e11cb154e68fc1e05e8d5a to your computer and use it in GitHub Desktop.
post-receive
This file contains hidden or 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 | |
GIT_DIR=/home/deploy/[app_name] | |
WORK_TREE=/var/www/[app_name] | |
export DATABASE_USER='' | |
export DATABASE_PASSWORD='' | |
export RAILS_ENV=staging | |
. ~/.zshrc | |
while read oldrev newrev ref | |
do | |
if [[ $ref =~ .*/master$ ]]; | |
then | |
echo "Master ref received. Deploying master branch to production..." | |
mkdir -p $WORK_TREE | |
git --work-tree=$WORK_TREE --git-dir=$GIT_DIR checkout -f | |
mkdir -p $WORK_TREE/shared/pids $WORK_TREE/shared/sockets $WORK_TREE/shared/log | |
# start deploy tasks | |
cd $WORK_TREE | |
bundle install | |
rake db:create | |
rake db:migrate | |
rake assets:precompile | |
sudo restart puma-manager | |
sudo service nginx restart | |
# end deploy tasks | |
echo "Git hooks deploy complete" | |
else | |
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment