Skip to content

Instantly share code, notes, and snippets.

@Yuffster
Created May 26, 2012 09:39
Show Gist options
  • Save Yuffster/2793154 to your computer and use it in GitHub Desktop.
Save Yuffster/2793154 to your computer and use it in GitHub Desktop.
Continuous Integration Server in < 20 Lines
require 'rubygems'
require 'sinatra'
require 'json'
require 'logger'
before do
#only allow access to GitHub.
ips = ['207.97.227.253', '50.57.128.197', '108.171.174.178'];
halt 404, "D:&lt;" unless ips.find_index(@env['REMOTE_ADDR'])>=0
end
post '/post-receive' do
branch = JSON.parse(params[:payload])['ref'].split('/').pop
log = Logger.new('log.txt').info(`./update_branch.sh #{branch}`)
end
#!/usr/bin/env bash
echo updating branch $1...
cd /srv/mysite.com/$1/application
git pull
touch tmp/restart.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment