Last active
July 17, 2021 19:56
-
-
Save hdevilbiss/3f6b735fd9037a519171ab49126861f4 to your computer and use it in GitHub Desktop.
WordPress Capistrano deployment script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :application, 'example.com' | |
set :repo_url, '[email protected]: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