Skip to content

Instantly share code, notes, and snippets.

@rafaelp
Created March 21, 2012 20:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save rafaelp/2152548 to your computer and use it in GitHub Desktop.
Save rafaelp/2152548 to your computer and use it in GitHub Desktop.
Rake task to synchronous continuous deployment of Rails application deployed on Heroku
# -*- encoding : utf-8 -*-
namespace :integration do
namespace :heroku do
task :add_remote do
sh "git remote add staging git@heroku.com:nomedoprojeto-staging.git" if `git remote |grep staging`.strip.blank?
sh "git remote add production git@heroku.com:com:nomedoprojeto-production.git" if `git remote |grep production`.strip.blank?
end
task :check do
var = `heroku config -s --app nomedoprojeto-staging|grep INTEGRATING_BY`
integrating_by = var.split('=')[1]
integrating_by.strip! unless integrating_by.blank?
user = `whoami`.strip
if !integrating_by.blank? and integrating_by != user
p80 "Project is already being integrated by #{integrating_by}"
exit
end
end
task :lock do
user = `whoami`.strip
sh "heroku config:add INTEGRATING_BY=#{user} --app nomedoprojeto-staging"
end
task :unlock do
`heroku config:remove INTEGRATING_BY --app nomedoprojeto-staging`
end
end
end
INTEGRATION_TASKS = %w(
integration:start
integration:bundle_install
db:migrate
spec
integration:coverage_verify
integration:heroku:add_remote
integration:heroku:check
integration:heroku:lock
integration:hipchat:announce
integration:finish
heroku:deploy:staging
integration:hipchat:finish
integration:heroku:unlock
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment