Skip to content

Instantly share code, notes, and snippets.

@thcyron
Created July 27, 2012 14:37
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 thcyron/3188390 to your computer and use it in GitHub Desktop.
Save thcyron/3188390 to your computer and use it in GitHub Desktop.
#!/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