Capistrano task for uploading a blocking robots.txt
I wrote this up again today, same path as Sergio's answer essentially, but sharing robots-specific result might save someone time :)
namespace :deploy do
desc "Uploads a robots.txt that mandates the site as off-limits to crawlers"
task :block_robots, :roles => :app do
content = [
'# This is a staging site. Do not index.',
'User-agent: *',
'Disallow: /'
].join($/)
logger.info "Uploading blocking robots.txt"
put content, "#{current_path}/public/robots.txt"
end
end
Then trigger it from your staging recipe with something like
after "deploy:update_code", "deploy:block_robots"