dustin (owner)

Revisions

gist: 148055 Download_button fork
public
Public Clone URL: git://gist.github.com/148055.git
Embed All Files: show embed
github webhook receiver.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env ruby1.8
 
require 'rubygems'
require 'sinatra'
require 'json'
 
base_repo_path = "/home/buildbot/repos"
 
post '/' do
  push = JSON.parse(params[:payload])
  branch = push['ref']
  old = push['before']
  new = push['after']
  repo = push['repository']['name']
 
  repo_path = "#{base_repo_path}/#{repo}.git"
 
  system("git --git-dir #{repo_path} remote update")
  cmd = "/home/buildbot/bin/git_buildbot.py -c #{repo} -l /tmp/bb.log"
  IO.popen("env GIT_DIR=#{repo_path} #{cmd}", "w") do |p|
    p.write "#{old} #{new} #{branch}\n"
  end
  "I got a push to: #{branch} from #{old} to #{new}"
end