Created
March 18, 2012 08:13
Revisions
-
gbissett revised this gist
Mar 18, 2012 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ require 'sinatra' CODE_PATH = '/repo/lives/here' RVM_COMMAND = '[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm' -
gbissett created this gist
Mar 18, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ require 'sinatra' require 'haml' CODE_PATH = '/repo/lives/here' RVM_COMMAND = '[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm' UPDATE_COMMAND = 'git pull' BUILD_COMMAND = 'bundle && rake db:migrate && rake' def log(message='') File.open('build.log', 'a') {|log| log.puts "#{Time.now.utc} #{message}" } end get '/*' do `tail -n 1 build.log` end # POST from a github webhook triggers a build post '/*' do log 'building...' build_process = fork { exec "/bin/bash -c '#{RVM_COMMAND} && cd #{CODE_PATH} && #{BUILD_COMMAND}'" } Process.waitpid(build_process) if $?.exitstatus.to_i == 0 log 'pass' system "cd #{CODE_PATH} && .git/hooks/build-worked" else log 'fail' system "cd #{CODE_PATH} && .git/hooks/build-failed" end end