A deploy.rb that actually works!

Use the below.

Note that it lets you SVN multiple configs - just append .online to the server version and it’ll get stripped when you deploy it!

Use with my previous post about how to get command line SVN SSH in Windows.

set :application, “YourApp”
#set :repository, "svn+ssh://username@mysiteSSH/home/username/svn/YourApp/trunk"
set :repository, “svn+ssh://username@www.site.name/home/username/svn/YourApp/trunk”

^^^ needs to be set to this, not the putty session, or it breaks on server side

role :web, "site.name"
role :app, "site.name"
role :db, “site.name”, :primary => true

set :deploy_to, "/home/username/site.name"
set :user, "username"
set :use_sudo, false
set :checkout, “export”

desc "Restart the FCGI processes on the app server as a regular user."
task :restart, :roles => :app do
run "#{current_path}/script/process/reaper --dispatcher=dispatch.fcgi"

desc <<DESC
Rename all foo.online files in the project into just foo - eg
environment.rb.online -> environment.rb. Then just have environment.rb
(unversioned, environment.rb.online (versioned), and environment.rb.offline

Credit to mademoiselle, RubyPanther, & saizai on Freenode #rubyonrails for the hack
task :after_update_code, :roles => :app do

ruby -e ‘Dir.new(".").grep(/.online$/){|f|File.rename f, $`}’

#ruby -e 'Dir.glob("**/*.online").each{|f|new = f.to_s.sub!(/.gz$/,""); File.rename f, new }'
run "find . -name ‘*online’ | while read foo; do mv $foo echo $foo | sed -e 's/.online//'; done"
run “find . -name ‘.*online’ | while read foo; do mv $foo echo $foo | sed -e 's/.online//'; done”

^^ for e.g. .htaccess