Skip to content

Instantly share code, notes, and snippets.

@arthur-feral
Created November 23, 2014 20:56
Show Gist options
  • Save arthur-feral/95c264fc0655dbe84e8f to your computer and use it in GitHub Desktop.
Save arthur-feral/95c264fc0655dbe84e8f to your computer and use it in GitHub Desktop.
Git hook for deploying rails application
#!/bin/bash -l
APP_NAME="rpi_server"
APP_PATH=/home/pi/Web/${APP_NAME}
GIT_PATH=/home/pi/usbdrv/${APP_NAME}.git
# Production environment
export RAILS_ENV="production"
echo "[DEPLOY] - Updating application working tree"
git --work-tree=${APP_PATH} --git-dir=${GIT_PATH} checkout -f
cd ${APP_PATH}
echo "[DEPLOY] - Linking Configuration and directories"
if [[ -f "config/database.yml.template" ]]; then
cp -v config/database.yml.sample config/database.yml
fi
echo "[DEPLOY] - Deplying application"
bundle install --deployment --without=development:test
bundle exec rake server:stop
bundle exec rake db:migrate
bundle exec rake assets:precompile
mkdir -p tmp/
bundle exec rake server:start
touch tmp/restart.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment