Skip to content

Instantly share code, notes, and snippets.

@markstory
Created October 19, 2015 03:50
Show Gist options
  • Save markstory/53e8b4efd8882bbcb406 to your computer and use it in GitHub Desktop.
Save markstory/53e8b4efd8882bbcb406 to your computer and use it in GitHub Desktop.
# This requires capistrano 2.x and fails horribly with 3.x
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
load 'config/deploy' # remove this line to skip loading any of the default tasks
# mark-story.com capistrano file
set :application, "mark-story.com"
set :repository, "/Users/markstory/Sites/mark_story/site/"
set :branch, "master"
set :scm, :git
# Deploy settings
set :deploy_to, "/home/markstory/public_html/#{application}"
set :deploy_via, :copy
set :copy_exclude, [".git/*", ".gitignore"]
set :copy_compression, :gzip
set :copy_via, :scp
# Use account tmp dir as /tmp is fucked.
set :copy_remote_dir, '/home/markstory/tmp'
# Options
set :use_sudo, false
set :keep_releases, 5
# Roles & servers
role :app, "173.255.203.165"
server '173.255.203.165', :app, :primary => true
set :user, 'markstory'
# Environments
task :production do
end
# Deployment tasks
namespace :deploy do
desc "Override the original :restart"
task :restart, :roles => :app do
deploy.install_composer
deploy.clear_cache
deploy.build_assets
end
task :finalize_update, :roles => :app do
# Link configuration files
run "ln -s #{shared_path}/config/app_local.php #{current_release}/config/app_local.php"
# Link uploaded files.
run "rm -rf #{current_release}/webroot/img/downloads;
ln -s #{shared_path}/webroot/downloads #{current_release}/webroot/img/downloads"
run "rm -rf #{current_release}/webroot/img/portfolio;
ln -s #{shared_path}/webroot/portfolio #{current_release}/webroot/img/portfolio"
run "ln -s #{shared_path}/webroot/files #{current_release}/webroot/files"
run "ln -s #{shared_path}/webroot/demos #{current_release}/webroot/demos"
# Link tmp
run "rm -rf #{current_release}/tmp"
run "ln -s #{shared_path}/tmp #{current_release}/tmp"
# Logs
run "rm -rf #{current_release}/logs"
run "ln -s #{shared_path}/log #{current_release}/logs"
end
desc <<-DESC
Install dependencies with composer.
DESC
task :install_composer do
run "cd #{current_release} && #{shared_path}/composer.phar install --no-dev --prefer-dist"
end
desc <<-DESC
Blow up all the cache files CakePHP uses, ensuring a clean restart.
DESC
task :clear_cache do
# Remove absolutely everything from TMP
run "rm -rf #{shared_path}/tmp/*"
# Create TMP folders
run "mkdir -p #{shared_path}/tmp/cache/models"
run "mkdir -p #{shared_path}/tmp/cache/persistent"
run "mkdir -p #{shared_path}/tmp/cache/views"
run "mkdir -p #{shared_path}/logs"
run "mkdir -p #{shared_path}/tmp/sessions"
run "chmod -R 0777 #{shared_path}/tmp"
end
desc <<-DESC
Generate assets using asset compress.
DESC
task :build_assets do
run "#{latest_release}/bin/cake asset_compress.asset_compress clear"
run "#{latest_release}/bin/cake asset_compress.asset_compress build"
end
end
namespace :pending do
desc <<-DESC
Displays the `diff' since your last deploy. This is useful if you want \
to examine what changes are about to be deployed. Note that this might \
not be supported on all SCM's.
DESC
task :diff, :except => { :no_release => true } do
system(source.local.diff(current_revision))
end
desc <<-DESC
Displays the commits since your last deploy. This is good for a summary \
of the changes that have occurred since the last deploy. Note that this \
might not be supported on all SCM's.
DESC
task :default, :except => { :no_release => true } do
from = source.next_revision(current_revision)
system(source.local.log(from))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment