Skip to content

Instantly share code, notes, and snippets.

@AFlowOfCode
Created April 24, 2018 17:00
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 AFlowOfCode/70ca8079d7bf36eb2a35ec956e97fae2 to your computer and use it in GitHub Desktop.
Save AFlowOfCode/70ca8079d7bf36eb2a35ec956e97fae2 to your computer and use it in GitHub Desktop.
Simple bash script to update & restart a rails app on a live dev server when triggered by a webhook set to repo push. Args to script are: head_commit.id, pusher.name, pusher.email
#!/bin/sh
echo "commit: $1 by: $2 $3"
cd your/git_rails/project_root #REPLACE THIS
git pull
if [ -f tmp/pids/server.pid ]; then
echo "killing rails server"
kill -9 $(cat tmp/pids/server.pid)
fi
bundle install
rails db:migrate RAILS_ENV=development
rails s -b 0.0.0.0 -d
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment