Skip to content

Instantly share code, notes, and snippets.

@shavit
Created October 20, 2014 20:30
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 shavit/ca4ab56b77c8a9801711 to your computer and use it in GitHub Desktop.
Save shavit/ca4ab56b77c8a9801711 to your computer and use it in GitHub Desktop.
Git deployment for Ruby on Rails applications in production
#!/bin/sh
APP_PATH=/var/www/app
# Production environment
export RAILS_ENV="production"
exit_with_error(){
echo "---> An Error Has Occurred!"
}
echo "---> Receiving push"
git --work-tree=/var/www/app --git-dir=/var/repositories/app.git checkout -f
echo "---> Changing directory to the application path"
cd ${APP_PATH}
echo "---> Compiling assets"
bundle exec rake assets:precompile
echo "---> Installing gems via bundler"
bundle install --deployment --without development test --path APP_PATH || exit_with_error
echo "---> Migrating database"
bundle exec rake db:migrate || exit_with_error
echo "---> Restart App"
restart app
echo "---> Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment