Create a gist now

Instantly share code, notes, and snippets.

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']
# 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"
task :migrate, :roles => :db do
run "phing -f #{latest_release}/build.xml migrate-db"
role :web, ''
role :db, '', :primary => true
set :deploy_to, '/var/www/vhosts/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment