Skip to content

Commit

Permalink
first stab at github webhook support
Browse files Browse the repository at this point in the history
  • Loading branch information
obfuscurity committed Jul 22, 2012
1 parent 48e73b3 commit 1571f72
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/backstop/web.rb
Expand Up @@ -55,6 +55,23 @@ def sockets
"ok"
end

post '/github' do
begin
data = JSON.parse(request.body.read)
rescue JSON::ParserError
halt 400, "JSON is required"
end
halt 400, "missing fields" unless (data['repository'] && data['commits'])
data["source"] = "github"
data["ref"].gsub!(/\//, ".")
data["commits"].each do |commit|
measure_time = DateTime.parse(commit["timestamp"]).strftime("%s")
s = sockets.sample
s.puts "#{data['source']}.#{data['ref']}.#{commit['id']} 1 #{measure_time}"
end
"ok"
end

post '/publish/:name' do
begin
data = JSON.parse(request.body.read)
Expand Down

0 comments on commit 1571f72

Please sign in to comment.