Created
July 27, 2012 14:37
-
-
Save thcyron/3188390 to your computer and use it in GitHub Desktop.
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/sh | |
step() { | |
echo "-----> $@" | |
} | |
run() { | |
$* 2>&1 | while read line; do | |
echo " $line" | |
done | |
} | |
STARTTIME="$(date +%s)" | |
. "$HOME/env.sh" | |
export GIT_DIR=".git" | |
cd "$HOME/app" | |
# Create directories that might be missing | |
run mkdir -p tmp/cache/ | |
run mkdir -p tmp/pids/ | |
run mkdir -p tmp/sockets/ | |
run mkdir -p log/ | |
step Resetting code from master branch... | |
run git fetch origin | |
run git reset --hard origin/master | |
step Running bundle... | |
run bundle install --without development test | |
step Copying Unicorn config... | |
run rm -f config/unicorn.conf.rb | |
run cp ../config/unicorn.conf.rb config/ | |
step Copying database config... | |
run rm -f config/database.yml | |
run cp ../config/database.yml config/ | |
changed_files="$(git diff @{1} --name-only)" | |
if [ "$(echo "$changed_files" | grep ^db/migrate/)" ]; then | |
step Running migrations... | |
run bundle exec rake db:migrate | |
else | |
step No need to run migrations | |
fi | |
#step Precompiling assets... | |
#run bundle exec rake assets:precompile | |
step "Restarting app..." | |
$HOME/restart.sh | |
DURATION="$(($(date +%s) - $STARTTIME))" | |
step Deployment done in $DURATION seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment