Skip to content

Instantly share code, notes, and snippets.

@coderberry
Last active August 29, 2015 14:24
Show Gist options
  • Save coderberry/5211a5cb9a5d8597c6fe to your computer and use it in GitHub Desktop.
Save coderberry/5211a5cb9a5d8597c6fe to your computer and use it in GitHub Desktop.
Get deploy status for Cloud66 in your terminal
require 'typhoeus'
require 'json'
STATUSES = {
0 => 'Pending',
1 => 'Deployed',
2 => 'Deployment failed',
3 => 'Analyzing',
4 => 'Analyzed',
5 => 'Queued for deployment',
6 => 'Deploying',
7 => 'Unable to analyze'
}
NAME = 'MY STACK NAME'
TOKEN = File.read("/Users/eberry/.cloud66/token")
current_status = 0
while current_status != 1
request = Typhoeus::Request.new(
"https://app.cloud66.com/api/3/stacks.json",
method: :get,
headers: { Authorization: "Bearer #{TOKEN}" }
)
request.run
response = request.response
resp = JSON.parse(response.body)
resp['response'].each do |data|
if data['name'] == NAME
if current_status == data['status']
print "."
else
print STATUSES[data['status']]
end
current_status = data['status']
end
end
sleep 5 unless current_status == 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment