diff --git a/script/ci_deploy b/script/ci_deploy deleted file mode 100755 index eb9aefd..0000000 --- a/script/ci_deploy +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env ruby - -# Deploy app to heroku with semaphoreapp -# http://fs.github.com/dev/ci-semaphoreapp -# -# Usage: -# script/ci_deploy branch heroku-app-name heroku-colloborator-private-key-encoded-with-base64 heroku-colloborator-api-key -# Options: -# * branch - will trigger deploy only for this brunch -# * 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 -# * heroku-colloborator-api-key - user's API key requred for run heroku run rake db:migrate - -require 'fileutils' -require 'base64' - -BRANCH = ARGV.shift -HEROKU_APP = ARGV.shift -KEY_BASE64 = ARGV.shift -API_KEY = ARGV.shift -CURRENT_BRANCH = ENV['BRANCH_NAME'] - -def prepare_ssh - ssh_dir = File.expand_path('~/.ssh') - - FileUtils.mkdir(ssh_dir) unless File.exists?(ssh_dir) - - File.open("#{ssh_dir}/id_rsa", 'w') do |file| - file.write(Base64.decode64(KEY_BASE64)) - end - - File.open("#{ssh_dir}/config", 'a') do |file| - file << <<-HOST - Host *heroku.com* - StrictHostKeyChecking no - UserKnownHostsFile=/dev/null - HOST - end - - File.chmod(0600, "#{ssh_dir}/id_rsa") -end - -def prepare_git - system('git remote rm heroku 2>/dev/null') - system("git remote add heroku git@heroku.com:#{HEROKU_APP}.git") || exit(1) -end - -def deploy - system("git push --force heroku #{BRANCH}:master") || exit(1) -end - -def run_migrations - system("env HEROKU_API_KEY=#{API_KEY} bundle exec heroku run rake db:migrate") || exit(1) -end - -if CURRENT_BRANCH == BRANCH - puts "Going to deploy #{BRANCH}..." - - prepare_ssh - prepare_git - deploy - run_migrations - - puts "Deployed!" -else - puts "Only #{BRANCH} allowed for depoy." -end \ No newline at end of file