Skip to content

Instantly share code, notes, and snippets.

@hdevilbiss
Last active July 17, 2021 19:56
Show Gist options
  • Save hdevilbiss/3f6b735fd9037a519171ab49126861f4 to your computer and use it in GitHub Desktop.
Save hdevilbiss/3f6b735fd9037a519171ab49126861f4 to your computer and use it in GitHub Desktop.
WordPress Capistrano deployment script
set :application, 'example.com'
set :repo_url, 'git@github.com:username/repo.git'
set :username, -> {'webHostUsername'}
# Git Branch Options
# ask :branch, -> { `git rev-parse --abbrev-ref HEAD`.chomp }
set :branch, :main
# Paths
set :proj_root, -> {"/home/#{fetch(:username)}/domains/#{fetch(:application)}"}
set :tmp_dir, -> {"#{fetch(:deploy_to)}/tmp"}
# Linked Files
set :linked_files, fetch(:linked_files, []).push(".env","web/.htaccess")
set :linked_dirs, fetch(:linked_dirs, []).push("web/app/uploads")
# Task
# :public_symlink_location is defined in production.rb and/or staging.rb
# @link https://capistranorb.com/documentation/faq/how-can-i-access-stage-configuration-variables/
namespace :deploy do
namespace :symlink do
desc "Remove public_html and replace with a symlink named public_html to the current/web folder"
task :release_public_html do
on roles :app do
within fetch(:proj_root) do
execute "rm","-rf","#{fetch(:public_symlink_location)}"
execute "ln","-sf","#{current_path}/web","#{fetch(:public_symlink_location)}"
end
end
end
end
end
# Hook
after "deploy:symlink:release", "deploy:symlink:release_public_html"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment