osem-fcy/config/deploy.rb

58 lines
1.8 KiB
Ruby
Raw Normal View History

2014-07-07 16:08:53 +02:00
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
2013-01-07 09:04:09 +01:00
2014-07-07 16:08:53 +02:00
set :domain, 'proxy-opensuse.suse.de'
set :port, 2214
set :user, 'osem'
set :deploy_to, '/srv/www/vhosts/opensuse.org/events'
set :repository, 'https://github.com/openSUSE/osem.git'
2013-01-07 09:04:09 +01:00
2014-07-07 16:08:53 +02:00
# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server.
# They will be linked in the 'deploy:link_shared_paths' step.
set :shared_paths, %w{ config/database.yml log public/system config/secrets.yml config/config.yml tmp}
2014-07-21 14:49:05 +02:00
task setup: :environment do
2014-07-07 16:08:53 +02:00
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"]
2013-01-07 09:04:09 +01:00
2014-07-07 16:08:53 +02:00
queue! %[touch "#{deploy_to}/shared/config/database.yml"]
queue! %[touch "#{deploy_to}/shared/system"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/system"]
queue %[echo "-----> Be sure to edit 'shared/config/database.yml'."]
2013-01-07 09:04:09 +01:00
end
2014-07-07 16:08:53 +02:00
desc 'Deploys the current version to the server.'
2014-07-21 14:49:05 +02:00
task deploy: :environment do
to :prepare do
queue "cd #{deploy_to}/current && RAILS_ENV=production bin/delayed_job stop"
end
2014-07-07 16:08:53 +02:00
deploy do
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
invoke :notify_errbit
2014-07-07 16:08:53 +02:00
to :launch do
queue "sudo /etc/init.d/apache2 restart"
queue "cd #{deploy_to}/current && RAILS_ENV=production bin/delayed_job start"
2014-07-07 16:08:53 +02:00
end
invoke :'deploy:cleanup'
2014-07-07 16:08:53 +02:00
end
end
2014-07-17 10:19:13 +02:00
desc 'Notifies the exception handler of the deploy.'
task :notify_errbit do
2014-07-17 10:19:13 +02:00
revision = `git rev-parse HEAD`.strip
user = ENV['USER']
queue "bundle exec rake hoptoad:deploy TO=#{rails_env} REVISION=#{revision} REPO=#{repository} USER=#{user}"
end