Skip to content

Instantly share code, notes, and snippets.

@viccherubini
Created November 10, 2012 11:31
Show Gist options
  • Save viccherubini/4050835 to your computer and use it in GitHub Desktop.
Save viccherubini/4050835 to your computer and use it in GitHub Desktop.
Symfony Capistrano deployment
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
load 'config/deploy' # remove this line to skip loading any of the default tasks
before 'deploy:create_symlink', 'deploy:build'
before 'deploy:create_symlink', 'deploy:migrate'
set :stages, %w(production staging)
set :default_stage, 'staging'
require 'capistrano/ext/multistage'
devs = {} and remotes = `git remote -v`.each_line {|s| devs[s.split(' ')[0]] = s.split(' ')[1] }
dev = ENV['DEV'] || 'origin'
unless repo = devs[dev]
repo = devs['origin']
end
# Repo options
set :application, 'Sample Symfony Application'
set :repository, repo
set :scm, :git
# Github stuff
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
# Deployment options
set :branch, ENV['BRANCH'] || 'master'
set :deploy_env, 'production'
set :use_sudo, false
set :user, 'deploy'
namespace :deploy do
task :build, :roles => :web do
run "phing -f #{latest_release}/build.xml -Dbuild_settings_file=#{shared_path}/system/build.settings -Dvendor_path=#{shared_path}/system/vendor"
end
task :migrate, :roles => :db do
run "phing -f #{latest_release}/build.xml migrate-db"
end
end
role :web, 'your-website.com'
role :db, 'db.your-website.com', :primary => true
set :deploy_to, '/var/www/vhosts/your-website.com'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment