This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.rb
74 lines (63 loc) · 2.51 KB
/
deploy.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
set :application, 'html'
set :repo_url, 'git@example.com:me/my_repo.git'
# Branch options
# Prompts for the branch name (defaults to current branch)
#ask :branch, -> { `git rev-parse --abbrev-ref HEAD`.chomp }
# Hardcodes branch to always be master
# This could be overridden in a stage config file
set :branch, :master
set :deploy_to, -> { "/srv/www/#{fetch(:application)}" }
# Use :debug for more verbose output when troubleshooting
set :log_level, :info
# Apache users with .htaccess files:
# it needs to be added to linked_files so it persists across deploys:
# set :linked_files, fetch(:linked_files, []).push('.env', 'web/.htaccess')
set :linked_files, fetch(:linked_files, []).push('.env')
set :linked_dirs, fetch(:linked_dirs, []).push('web/app/uploads')
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
# execute :service, :nginx, :reload
end
end
end
# The above restart task is not run by default
# Uncomment the following line to run it on deploys if needed
# after 'deploy:publishing', 'deploy:restart'
namespace :deploy do
desc 'Update WordPress template root paths to point to the new release'
task :update_option_paths do
on roles(:app) do
within fetch(:release_path) do
if test :wp, :core, 'is-installed'
[:stylesheet_root, :template_root].each do |option|
# Only change the value if it's an absolute path
# i.e. The relative path "/themes" must remain unchanged
# Also, the option might not be set, in which case we leave it like that
value = capture :wp, :option, :get, option, raise_on_non_zero_exit: false
if value != '' && value != '/themes'
execute :wp, :option, :set, option, fetch(:release_path).join('web/wp/wp-content/themes')
end
end
end
end
end
end
end
# The above update_option_paths task is not run by default
# Note that you need to have WP-CLI installed on your server
# Uncomment the following line to run it on deploys if needed
# after 'deploy:publishing', 'deploy:update_option_paths'
namespace :deploy do
desc 'Changing file permissions and ownership'
task :perms do
on roles(:app) do
execute "sudo chown -R www-data:deploy #{release_path}/web"
execute "sudo chown -R www-data:deploy #{current_path}/web"
execute "sudo chown -R www-data:deploy #{shared_path}/web"
end
end
end
after "deploy:finished", 'deploy:perms'