Skip to content

Instantly share code, notes, and snippets.

@basmoura
Last active August 29, 2015 13:58
Show Gist options
  • Save basmoura/9958140 to your computer and use it in GitHub Desktop.
Save basmoura/9958140 to your computer and use it in GitHub Desktop.
Deploy cfg with mina
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
set :user, 'ubuntu'
set :domain, 'example.com'
set :deploy_to, 'path'
set :repository, 'git repository url'
set :branch, 'master'
set :ssh_options, '-A'
set :shared_paths, ['config/database.yml', 'log']
task :environment do
invoke :'rvm:use[ruby-2.1.0@default]'
end
task :setup => :environment do
queue! %[mkdir -p "#{deploy_to}/shared/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"]
queue! %[mkdir -p "#{deploy_to}/shared/config"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/config"]
queue! %[touch "#{deploy_to}/shared/config/database.yml"]
queue %[echo "-----> Be sure to edit 'shared/config/database.yml'."]
end
task :whenever => :environment do
queue! %[cd "#{deploy_to}/current"]
queue! %[whenever --write-crontab]
end
desc "Deploys the current version to the server."
task :deploy => :environment do
deploy do
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
to :launch do
invoke :whenever
queue "sudo /etc/init.d/nginx restart"
invoke :'deploy:cleanup'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment