Skip to content

Instantly share code, notes, and snippets.

@treeder
Created April 5, 2012 06:06
Show Gist options
  • Select an option

  • Save treeder/2308369 to your computer and use it in GitHub Desktop.

Select an option

Save treeder/2308369 to your computer and use it in GitHub Desktop.
require 'cgi'
require 'yaml'
require 'hipchat-api'
cgi_parsed = CGI::parse(payload)
log "cgi_parsed: #{cgi_parsed.inspect}"
parsed = JSON.parse(cgi_parsed['payload'][0])
log "parsed: #{parsed.inspect}"
webhook_config = YAML.load_file('webhook_config.yml')
log "webhook_config: #{webhook_config.inspect}"
hipchat = HipChat::API.new(webhook_config['hipchat']['api_key'])
parsed['commits'].each do |c|
log hipchat.rooms_message(webhook_config['hipchat']['room'], 'WebhookWorkerNG', "Rev: <a href=\"#{c['url']}\">#{c['id'][0,9]}</a> - #{c['message']}", true).body
end
require 'iron_worker_ng'
require_relative '../../ruby/examples_helper'
config = ExamplesHelper.load_config
client = IronWorkerNG::Client.new(:token => config['iw']['token'], :project_id => config['iw']['project_id'])
code = IronWorkerNG::Code::Ruby.new
code.merge_worker 'github_to_hipchat_webhook_worker.rb'
code.merge_file 'webhook_config.yml'
code.merge_gem 'hipchat-api'
client.codes.create(code)
url = "https://worker-aws-us-east-1.iron.io/2/projects/#{config['iw']['project_id']}/tasks/webhook?code_name=#{code.name}&oauth=#{config['iw']['token']}"
puts "Add this url to github Service Hooks, Post Receive URLs: "
puts url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment