Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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