Last active
June 9, 2016 06:55
-
-
Save shoken0x/118c5ec8eaf658c7e6b6e9a882170a3b to your computer and use it in GitHub Desktop.
Github Webhook Server for deploy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rails_restart.sh is simple shell program. you can get somewhere. | |
require 'webrick' | |
require 'json' | |
server = WEBrick::HTTPServer.new(Port: 8000, ServerType: WEBrick::Daemon) | |
server.mount_proc '/' do |req, res| | |
req_json = JSON.parse(req.body) | |
if req_json["ref"] == "refs/heads/master" | |
system "cd /path_to_rails_project && git pull && bundle exec rake assets:precompile RAILS_ENV=production && bundle install && rails_restart.sh" | |
end | |
end | |
trap 'INT' do server.shutdown end | |
server.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment