Skip to content

Instantly share code, notes, and snippets.

@shavit
Created March 9, 2016 02:15
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/32b7625c46aa064efc8a to your computer and use it in GitHub Desktop.
Save shavit/32b7625c46aa064efc8a to your computer and use it in GitHub Desktop.
Ruby on Rails post receive file for Git deployments.
#!/bin/sh
APP_PATH=$APP_ROOT
exit_with_error(){
echo "---> An Error Has Occurred!"
}
echo "---> Receiving push as $USER"
git --work-tree=$APP_PATH --git-dir=$GIT_DIR checkout -f
echo "---> Changing directory to the application path"
cd ${APP_PATH}
export GEM_PATH=/home/$USER/.rvm/gems/ruby-2.3.0:/home/$USER/.rvm/gems/ruby-2.3.0@global
export PATH=/home/$USER/.rvm/gems/ruby-2.3.0/bin:/home/$USER/.rvm/gems/ruby-2.3.0@global/bin:/home/$USER/.rvm/rubies/ruby-2.3.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/$USER/.rvm/bin:/home/$USER/.rvm/bin:/home/$USER/.rvm/bin
echo "---> Installing with bundler"
RAILS_ENV=production bundle install
echo "---> Migrating the database"
RAILS_ENV=production rake db:migrate
echo "---> Precompiling assets"
RAILS_ENV=production rake assets:precompile
echo "---> Setting permissions to /home/$USER/.rvm "
chown $USER /home/$USER/.rvm -R
# echo "---> Restarting the application"
# restart app
echo "---> Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment