Forked from semipermeable/tddium_post_build.rake
Created
October 5, 2012 10:30
Revisions
-
jensendarren revised this gist
Oct 6, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -48,11 +48,12 @@ namespace :tddium do new_relic_api_key = ENV["NEW_RELIC_API_KEY"] application_id = ENV["NEW_RELIC_APPLICATION_ID"] user_name = ENV['TDDIUM_USER_NAME'] if new_relic_api_key && application_id NewRelicApi.api_key = new_relic_api_key NewRelicApi::Deployment.create :application_id => application_id, :user => user_name end end -
jensendarren revised this gist
Oct 5, 2012 . 1 changed file with 11 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -45,5 +45,15 @@ namespace :tddium do puts "Restarting Heroku..." cmd "bundle exec heroku restart --app #{app_name}" or abort "aborted heroku restart" new_relic_api_key = ENV["NEW_RELIC_API_KEY"] application_id = ENV["NEW_RELIC_APPLICATION_ID"] if new_relic_api_key && application_id NewRelicApi.api_key = new_relic_api_key NewRelicApi::Deployment.create :application_id => application_id, :description => "Should be the commit sha", :user => "Should be the user who push" end end end -
semipermeable revised this gist
Aug 8, 2012 . 1 changed file with 13 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,9 +12,6 @@ namespace :tddium do return unless ENV["TDDIUM_MODE"] == "ci" return unless ENV["TDDIUM_BUILD_STATUS"] == "passed" dir = File.expand_path("~/.heroku/") heroku_email = ENV["HEROKU_EMAIL"] heroku_api_key = ENV["HEROKU_API_KEY"] @@ -32,10 +29,21 @@ namespace :tddium do f.write("\n") end File.open(File.expand_path("~/.netrc"), "a+") do |f| ['api', 'code'].each do |host| f.puts "machine #{host}.heroku.com" f.puts " login #{heroku_email}" f.puts " password #{heroku_api_key}" end end puts "Pushing to Heroku: #{push_target}..." cmd "git push #{push_target} HEAD:master --force" or abort "could not push to #{push_target}" puts "Running Heroku Migrations..." cmd "heroku run rake db:migrate --app #{app_name}" or abort "aborted migrations" puts "Restarting Heroku..." cmd "bundle exec heroku restart --app #{app_name}" or abort "aborted heroku restart" end end -
semipermeable revised this gist
May 9, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ namespace :tddium do dir = File.expand_path("~/.heroku/") heroku_email = ENV["HEROKU_EMAIL"] heroku_api_key = ENV["HEROKU_API_KEY"] current_branch = `git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3-`.strip app_name = ENV["HEROKU_APP_NAME"] push_target = "[email protected]:#{app_name}.git" -
semipermeable revised this gist
May 8, 2012 . 1 changed file with 15 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,15 @@ end namespace :tddium do desc "post_build_hook" task :post_build_hook do # This build hook should only run after CI builds. # # There are other cases where we'd want to run something after every build, # or only after manual builds. return unless ENV["TDDIUM_MODE"] == "ci" return unless ENV["TDDIUM_BUILD_STATUS"] == "passed" puts "Resetting workspace to HEAD" cmd "git reset --hard HEAD" or abort "could not reset git workspace" dir = File.expand_path("~/.heroku/") heroku_email = ENV["HEROKU_EMAIL"] @@ -14,9 +22,9 @@ namespace :tddium do app_name = ENV["HEROKU_APP_NAME"] push_target = "[email protected]:#{app_name}.git" abort "invalid current branch" unless current_branch FileUtils.mkdir_p(dir) or abort "Could not create #{dir}" puts "Writing Heroku Credentials" File.open(File.join(dir, "credentials"), "w") do |f| @@ -25,9 +33,9 @@ namespace :tddium do end puts "Pushing to Heroku: #{push_target}..." cmd "git push #{push_target} #{current_branch}:master --force" or abort "could not push to #{push_target}" puts "Running Heroku Migrations..." cmd "heroku run rake db:migrate --app #{app_name}" or abort "aborted to run migrations" end end -
semipermeable created this gist
May 8, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ def cmd(c) system c end namespace :tddium do desc "post_build_hook" task :post_build_hook do cmd "git reset --hard HEAD" or fail "could not reset git workspace" dir = File.expand_path("~/.heroku/") heroku_email = ENV["HEROKU_EMAIL"] heroku_api_key = ENV["HEROKU_API_KEY"] current_branch = `git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3`.strip app_name = ENV["HEROKU_APP_NAME"] push_target = "[email protected]:#{app_name}.git" fail "invalid current branch" unless current_branch FileUtils.mkdir_p(dir) or fail "Could not create #{dir}" puts "Writing Heroku Credentials" File.open(File.join(dir, "credentials"), "w") do |f| f.write([heroku_email, heroku_api_key].join("\n")) f.write("\n") end puts "Pushing to Heroku: #{push_target}..." cmd "git push #{push_target} #{current_branch}:master --force" or fail "could not push to #{push_target}" puts "Running Heroku Migrations..." cmd "heroku run rake db:migrate --app #{app_name}" or fail "failed to run migrations" end end