Created
June 6, 2013 08:19
-
-
Save larstobi/5720092 to your computer and use it in GitHub Desktop.
Rack app to listen for POST from Github post receive hook.
This file contains 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 characters
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