Skip to content

Instantly share code, notes, and snippets.

@ezmobius
Created May 20, 2009 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ezmobius/114954 to your computer and use it in GitHub Desktop.
Save ezmobius/114954 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# solo.rb
def usage(message)
$stderr.puts message
$stderr.puts
$stderr.puts "#{File.basename($0)} envname [migrate]"
exit 1
end
envname = ARGV.shift || usage("Specify the envname")
migrate = ARGV.shift
token = `git config --get cloud.token`.chomp
if token.empty?
$stderr.puts <<-EOT
The cloud token is not set."
To store the token, use:
$ git config --add cloud.token SOMETOKEN
EOT
exit 2
end
commit = `git rev-parse HEAD`.chomp
payload = {
"commits" => [{"id" => commit, "message"=>"[deploy #{envname}#{migrate ? ' migrate' : ''}]"}],
"ref" => "refs/heads/master",
}
require 'rubygems'
require 'json'
require 'restclient'
puts "Triggering a deploy for #{commit} on #{envname}"
begin
response = RestClient.post("https://cloud.engineyard.com/github/#{token}",
:payload => payload.to_json)
puts "Successfully triggered the deploy"
rescue RestClient::RequestFailed => e
puts "Could not deploy your changes"
puts e.response.code
puts e.response.body
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment