Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@larstobi
Created June 6, 2013 08:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larstobi/5720092 to your computer and use it in GitHub Desktop.
Save larstobi/5720092 to your computer and use it in GitHub Desktop.
Rack app to listen for POST from Github post receive hook.
require 'rack'
module GithubPostReceiveServer
class RackApp
def handle_request
payload = @req.POST["payload"]
if payload.nil?
return Rack::Response.new('404 Not Found', 404)
end
ENV.delete('GIT_DIR')
$LOG.debug "Running r10k as UID #{Process.uid}..."
%x{/opt/puppet/bin/r10k deploy environment -p}
$LOG.debug "Done running r10k."
Rack::Response.new('OK', 200)
end
# Call is the entry point for all rack apps.
def call(env)
@req = Rack::Request.new(env)
@res = handle_request
@res.finish
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment