This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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