Skip to content

Commit

Permalink
Run migraions right after deploy to heroku with script/ci_deploy.
Browse files Browse the repository at this point in the history
Required HEROKU_API_KEY.
  • Loading branch information
dmitrytrager authored and timurvafin committed Oct 30, 2012
1 parent 60db7ac commit 14fcdff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ gem 'github-markdown' # only for dashboard controller
group :development do group :development do
gem 'quiet_assets' gem 'quiet_assets'
gem 'letter_opener' gem 'letter_opener'
gem 'heroku'
gem 'slim-rails' gem 'slim-rails'
gem 'foreman' gem 'foreman'
gem 'bullet' gem 'bullet'
Expand All @@ -45,6 +44,7 @@ group :development, :test do
gem 'mail_safe' gem 'mail_safe'
gem 'rails_best_practices' gem 'rails_best_practices'
gem 'brakeman' gem 'brakeman'
gem 'heroku'
end end


group :test do group :test do
Expand Down
7 changes: 5 additions & 2 deletions script/ci_deploy
Original file line number Original file line Diff line number Diff line change
@@ -1,20 +1,23 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby


# Deploy app to heroku with semaphoreapp # Deploy app to heroku with semaphoreapp
# http://fs.github.com/dev/ci-semaphoreapp
# #
# Usage: # Usage:
# script/ci_deploy branch heroku-app-name heroku-colloborator-private-key-encoded-with-base64 # script/ci_deploy branch heroku-app-name heroku-colloborator-private-key-encoded-with-base64 heroku-colloborator-api-key
# Options: # Options:
# * branch - will trigger deploy only for this brunch # * branch - will trigger deploy only for this brunch
# * heroku-app-name - name of your heroku application # * heroku-app-name - name of your heroku application
# * code will be pushed to git from user with this private key. Key should be encoded with base64: base64 /path/to/private_key # * code will be pushed to git from user with this private key. Key should be encoded with base64: base64 /path/to/private_key
# * heroku-colloborator-api-key - user's API key requred for run heroku run rake db:migrate


require 'fileutils' require 'fileutils'
require 'base64' require 'base64'


BRANCH = ARGV.shift BRANCH = ARGV.shift
HEROKU_APP = ARGV.shift HEROKU_APP = ARGV.shift
KEY_BASE64 = ARGV.shift KEY_BASE64 = ARGV.shift
API_KEY = ARGV.shift
CURRENT_BRANCH = ENV['BRANCH_NAME'] CURRENT_BRANCH = ENV['BRANCH_NAME']


def prepare_ssh def prepare_ssh
Expand Down Expand Up @@ -47,7 +50,7 @@ def deploy
end end


def run_migrations def run_migrations
system('bin/heroku run rake db:migrate') || exit(1) system("env HEROKU_API_KEY=#{API_KEY} bundle exec heroku run rake db:migrate") || exit(1)
end end


if CURRENT_BRANCH == BRANCH if CURRENT_BRANCH == BRANCH
Expand Down

0 comments on commit 14fcdff

Please sign in to comment.