Skip to content

Instantly share code, notes, and snippets.

@jdanbrown
Forked from gilesbowkett/heroku_style_baby.rb
Created November 15, 2013 01:02
Show Gist options
  • Save jdanbrown/7477414 to your computer and use it in GitHub Desktop.
Save jdanbrown/7477414 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sinatra'
require 'json'
class GitHubUpdater
def self.update?(json)
(JSON.parse(json)["ref"] == "refs/heads/master")
end
def self.git_pull
`cd /project/directory && git checkout master && git pull origin master`
end
end
set :port, 54321
post '/' do
GitHubUpdater.git_pull if GitHubUpdater.update?(params[:payload])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment