Created
June 26, 2013 13:15
-
-
Save resure/5867271 to your computer and use it in GitHub Desktop.
Hatbot deploy Capfile
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 characters
require 'railsless-deploy' | |
server 'scpfoundation.net', :web, :app, :db, primary: true | |
set :application, "hatbot" | |
set :user, "deployer" | |
set :use_sudo, false | |
set :scm, :git | |
set :ssh_options, { forward_agent: true } | |
set :branch, "master" | |
set :deploy_to, "/home/#{user}/apps/#{application}" | |
set :deploy_via, :remote_cache | |
set :repository, "[email protected]:resure/hatbot.git" | |
default_environment['PATH'] = "$PATH:#{deploy_to}/.node_modules/.bin:$HOME/.rbenv/shims:$HOME/.rbenv/bin" | |
after "deploy", "deploy:cleanup" | |
namespace :deploy do | |
%w[start stop restart].each do |command| | |
desc "#{command} app" | |
task command, roles: :app, expect: {no_release: true} do | |
run "sudo #{command} #{application}" | |
end | |
end | |
task :setup_config, roles: :app do | |
run "mkdir -p #{shared_path}/config" | |
put File.read(".env.sample"), "#{shared_path}/config/env" | |
puts "Now edit the config files in #{shared_path}." | |
end | |
after "deploy:setup", "deploy:setup_config" | |
before "deploy:finalize_update", "deploy:install_modules" | |
task :install_modules, roles: :app do | |
run "cd #{release_path} && npm install" | |
end | |
task :prepare_app, roles: :app do | |
run "ln -nfs #{shared_path}/config/env #{release_path}/.env" | |
run "cd #{release_path} && rbenv sudo foreman export --app #{application} --user #{user} upstart /etc/init" | |
end | |
after "deploy:finalize_update", "deploy:prepare_app" | |
desc "Make sure local git is in sync with remote." | |
task :check_revision, roles: :web do | |
unless `git rev-parse HEAD` == `git rev-parse origin/master` | |
puts "WARNING: HEAD is not the same as origin/master" | |
puts "Run `git push` to sync changes." | |
exit | |
end | |
end | |
before "deploy", "deploy:check_revision" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment