Skip to content

Instantly share code, notes, and snippets.

@favrik
Created February 16, 2011 11:46
Show Gist options
  • Save favrik/829252 to your computer and use it in GitHub Desktop.
Save favrik/829252 to your computer and use it in GitHub Desktop.
Deploy para php usando git y Capistrano
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
ssh_options[:forward_agent] = true
default_run_options[:pty] = true
set :application, "GDC"
set :repository, "git@github.com:noahlh/GDC-Online-Vehicle-Reservation-System.git"
set :scm, :git
set :deploy_via, :remote_cache
set :user, "deploy"
set :scm_username, "favrik"
set :use_sudo, false
namespace :deploy do
task :restart, :roles => :app, :except => { :no_release => true } do
# Do nothing!
end
task :gdc_setup do
run "touch #{current_release}/application/logs/authorize"
run "touch #{current_release}/application/logs/failed_update_calendar"
run "chmod 0777 #{current_release}/application/logs"
run "chmod 0666 #{current_release}/application/logs/*"
run "chmod 0777 #{current_release}/codeigniter/system/logs"
run "mkdir #{current_release}/public/templates/compile"
run "chmod 0777 #{current_release}/public/templates/compile"
run "mkdir #{current_release}/public/partners/temp/templates"
run "chmod 0777 #{current_release}/public/partners/temp/templates"
run "chmod 0777 #{current_release}/public/googleerror.log"
run "chmod 0777 #{current_release}/public/googlemessage.log"
run "cp #{current_release}/public/#{environment}.htaccess #{current_release}/public/.htaccess"
run "rm #{current_release}/public/production.htaccess"
run "rm #{current_release}/public/staging.htaccess"
run "rm #{current_release}/public/beta.htaccess"
run "rm #{current_release}/public/default.htaccess"
run "cp #{current_release}/public/admin/#{environment}.htaccess #{current_release}/public/admin/.htaccess"
run "rm #{current_release}/public/admin/production.htaccess"
run "rm #{current_release}/public/admin/staging.htaccess"
run "rm #{current_release}/public/admin/beta.htaccess"
end
task :beta_symlinks do
run "ln -s #{current_release}/application/tests #{current_release}/public/tests"
run "ln -s /home/gdcbeta/public_html/wiki #{current_release}/public/wiki"
run "ln -s /home/gdclive/public_html/news #{current_release}/public/news"
run "ln -s /home/gdclive/public_html/videos #{current_release}/public/videos"
run "ln -s /home/gdclive/public_html/awstats #{current_release}/public/awstats"
end
task :staging_symlinks do
run "mv #{current_release}/public/#{environment}.htpasswd #{current_release}/public/.htpasswd"
run "ln -s /home/gdclive/public_html/news #{current_release}/public/news"
run "ln -s /home/gdclive/public_html/videos #{current_release}/public/videos"
run "ln -s /home/gdclive/public_html/awstats #{current_release}/public/awstats"
end
task :production_symlinks do
run "ln -s /srv/www/gothamdreamcars.com/public/news #{current_release}/public/news"
run "ln -s /srv/www/gothamdreamcars.com/public/videos #{current_release}/public/videos"
end
after "deploy:symlink", "deploy:gdc_setup"
after "deploy", "deploy:cleanup"
end
task :beta do
role :web, "beta.gothamdreamcars.net"
set :environment, "beta"
set :branch, "master"
set :deploy_to, "/home/gdcbeta/deploy"
after "deploy:symlink", "deploy:beta_symlinks"
end
task :staging do
role :web, "staging.gothamdreamcars.net"
set :environment, "staging"
set :branch, "staging"
set :deploy_to, "/home/gdcstage/deploy"
after "deploy:symlink", "deploy:staging_symlinks"
end
task :production do
role :web, "live.gothamdreamcars.net"
set :environment, "production"
set :branch, "production"
set :deploy_to, "/srv/www/gothamdreamcars.com/deploy"
after "deploy:symlink", "deploy:production_symlinks"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment