Skip to content

Instantly share code, notes, and snippets.

@luki3k5
Created June 21, 2011 07:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save luki3k5/1037410 to your computer and use it in GitHub Desktop.
require 'rest-client' if RAILS_ENV == "development"
require 'scalarium-api-wrapper' if RAILS_ENV == "development"
namespace :my_application do
namespace :scalarium do
desc "deploy to development"
task :deploy_to_dev, :comment, :needs => :environment do |t, args|
if RAILS_ENV == "development"
config = YAML::load(File.open("#{RAILS_ROOT}/config/scalarium.yml"))
Scalarium.configuration.api_token = config["development"]["api_token"]
api = Scalarium::API.new
deployment_details = api.deploy_application(config["development"]["app_id"], :comment => "Deployed by: #{%x[whoami]} #{args[:comment]}")
STDOUT.sync = true
print "##{Time.now}# - please wait! Deploy is running... " if deployment_details["status"] == "running"
# checking the status and showing progress
while true do
deployment_details = api.fetch_deployment_details(config["development"]["app_id"], deployment_details["id"])
if deployment_details["status"] == "running"
sleep 20
print "."
else
print "DEPLOY COMPLETED! with status => #{deployment_details["status"]}\n"
break
end
end
else
puts "\n\n-------- -------- -------- -------- -------- -------- -------- -------- -------- --------"
puts " NOTE: This only works when RAILS_ENV == development - please make sure You run it in 'development'"
puts "-------- -------- -------- -------- -------- -------- -------- -------- -------- --------\n\n"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment