capistrano-sozo_magento2 1.3.1 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +5 -0
- data/CHANGELOG.md +31 -0
- data/README.md +1 -1
- data/lib/capistrano/sozo_magento2/defaults.rb +5 -2
- data/lib/capistrano/sozo_magento2/info.rb +64 -0
- data/lib/capistrano/sozo_magento2/slack.rb +4 -0
- data/lib/capistrano/sozo_magento2/version.rb +5 -1
- data/lib/capistrano/sozo_magento2.rb +10 -3
- data/lib/capistrano/tasks/composer.rake +1 -0
- data/lib/capistrano/tasks/db.rake +1 -1
- data/lib/capistrano/tasks/deploy.rake +16 -3
- data/lib/capistrano/tasks/magento2.rake +28 -10
- data/lib/capistrano/tasks/sozo.rake +27 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98c509eae724dea5c38746f591cb1038102bcce324373ef7ad1cb0f48c5ee604
|
4
|
+
data.tar.gz: 3da4dafb3310757ea46730200df4e48f3c6a2ebdf25d0536ea57cce0e46f37bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fd96c30e041efc3a73b598cb9866cbfed78f0e7013c6d647100b2149ca6354f2a111e5a08c13bd1909328a7f9a7f0dd7af28772511d8aa4fb5b5cd53c701abc
|
7
|
+
data.tar.gz: '08953c640d73eb088071f465a9ed8d8b61805c7d922cbde614cf050ab9c247a7cfdccd112f6a9baad214f477ffecfe8dd9ee688e6d240193893df95a425e0a12'
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
@@ -21,6 +21,37 @@ Given a version number MAJOR.MINOR.PATCH, increment the:
|
|
21
21
|
|
22
22
|
## [Unreleased]
|
23
23
|
|
24
|
+
## [v1.5.1] - 2022-02-23
|
25
|
+
### Changed
|
26
|
+
- Reverted change to magento:patches:apply
|
27
|
+
|
28
|
+
|
29
|
+
## [v1.5.0] - 2022-02-22
|
30
|
+
### Added
|
31
|
+
- Option to not clear files if the deployment fails via the `:clear_failures` option
|
32
|
+
- Option to await user input before putting site in maintenance mode with `:magento_deploy_confirm_roles`
|
33
|
+
|
34
|
+
### Changed
|
35
|
+
- Deployment task order to lower site downtime.
|
36
|
+
- WordPress twentytwentyone theme removed now by default.
|
37
|
+
|
38
|
+
### Removed
|
39
|
+
- magento:patches:apply command removed as it's part of the composer.bash ran at install time.
|
40
|
+
|
41
|
+
|
42
|
+
## [v1.4.0] - 2021-08-03
|
43
|
+
### Added
|
44
|
+
- New `deploy:check` info output with key information displayed.
|
45
|
+
- Magento Cron control now included in the deployment methods with `:handle_cron` option (default false).
|
46
|
+
- New check `sozo:git:check` to see if the branch exists in the repository before deployment begins.
|
47
|
+
- Documented code with Yardoc
|
48
|
+
|
49
|
+
### Changed
|
50
|
+
- Delay added (3 seconds) before trying to delete a failed deployment to allow file or disk activity to finish.
|
51
|
+
- Added sudo to failed deployments release deleting.
|
52
|
+
- Changed maintenance mode path to use the `deploy_root` location from `current_path`
|
53
|
+
- Checked all boolean values against string "true" or "false" using .to_s == 'true'
|
54
|
+
|
24
55
|
|
25
56
|
## [v1.3.1] - 2021-07-29
|
26
57
|
### Changed
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ set :keep_backups, fetch(:keep_backups, 10)
|
|
31
31
|
|
32
32
|
# WordPress integration defaults
|
33
33
|
set :wp_backup, fetch(:wp_backup, true)
|
34
|
-
set :wp_delete_themes, fetch(:wp_delete_themes, 'twentyseventeen twentynineteen twentytwenty')
|
34
|
+
set :wp_delete_themes, fetch(:wp_delete_themes, 'twentyseventeen twentynineteen twentytwenty twentytwentyone')
|
35
35
|
set :wp_delete_plugins, fetch(:wp_delete_plugins, 'hello')
|
36
36
|
set :wp_disable_plugins, fetch(:wp_disable_plugins, '')
|
37
37
|
|
@@ -42,6 +42,9 @@ set :slack_webhook, 'https://hooks.slack.com/services/T06K8GR2L/
|
|
42
42
|
# Deployment defaults
|
43
43
|
set :magento_deploy_confirm_roles, fetch(:magento_deploy_confirm_roles, [])
|
44
44
|
|
45
|
+
# Handle removing and installing of cron tasks?
|
46
|
+
set :handle_cron, fetch(:handle_cron, false)
|
47
|
+
|
45
48
|
# Other defaults (for future use)
|
46
49
|
# Clear or leave the failed deployment dirs
|
47
|
-
set :clear_failures, fetch(:clear_failures, true)
|
50
|
+
set :clear_failures, fetch(:clear_failures, true)
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require "capistrano/doctor/output_helpers"
|
2
|
+
|
3
|
+
include Capistrano::DSL
|
4
|
+
|
5
|
+
# @author Clive Walkden
|
6
|
+
module SozoMagento2
|
7
|
+
# Class to out key information at the end of the deploy:check command
|
8
|
+
module Info
|
9
|
+
# Class to out key information at the end of the deploy:check command
|
10
|
+
class Info
|
11
|
+
WHITELIST = %i(
|
12
|
+
branch
|
13
|
+
environment
|
14
|
+
handle_cron
|
15
|
+
slack_channel
|
16
|
+
url
|
17
|
+
).freeze
|
18
|
+
private_constant :WHITELIST
|
19
|
+
|
20
|
+
include Capistrano::Doctor::OutputHelpers
|
21
|
+
|
22
|
+
# Initialize the class with access to env data
|
23
|
+
def initialize(env=Capistrano::Configuration.env)
|
24
|
+
@env = env
|
25
|
+
end
|
26
|
+
|
27
|
+
# Output the key information in the CLI
|
28
|
+
def call
|
29
|
+
title("Deployment Info")
|
30
|
+
|
31
|
+
values = inspect_all_values
|
32
|
+
|
33
|
+
table(values.keys.sort_by(&:to_s)) do |key, row|
|
34
|
+
row.yellow if values[key] == "\"production\""
|
35
|
+
row << key.inspect
|
36
|
+
row << ''
|
37
|
+
row << values[key]
|
38
|
+
end
|
39
|
+
|
40
|
+
puts("")
|
41
|
+
warning("Make sure you check these values before deploying!")
|
42
|
+
puts("")
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
attr_reader :env
|
48
|
+
|
49
|
+
# Read all variables in
|
50
|
+
def variables
|
51
|
+
env.variables
|
52
|
+
end
|
53
|
+
|
54
|
+
# Only include variables in the whitelist
|
55
|
+
def inspect_all_values
|
56
|
+
variables.keys.each_with_object({}) do |key, inspected|
|
57
|
+
if WHITELIST.include?(key)
|
58
|
+
inspected[key] = variables.peek(key).inspect
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -2,8 +2,12 @@ require 'json'
|
|
2
2
|
|
3
3
|
include Capistrano::DSL
|
4
4
|
|
5
|
+
# @author Clive Walkden
|
5
6
|
module SozoMagento2
|
7
|
+
# Slack message template
|
6
8
|
module Slack
|
9
|
+
# Slack message template
|
10
|
+
# @return [String] the template hash
|
7
11
|
def message_hash
|
8
12
|
{
|
9
13
|
"channel" => fetch(:slack_channel),
|
@@ -17,15 +17,19 @@ load File.expand_path('../tasks/provision.rake', __FILE__)
|
|
17
17
|
load File.expand_path('../tasks/server.rake', __FILE__)
|
18
18
|
load File.expand_path('../tasks/wordpress.rake', __FILE__)
|
19
19
|
|
20
|
+
after 'deploy:check', 'sozo:git:check'
|
21
|
+
after 'deploy:check', 'sozo:info'
|
22
|
+
|
20
23
|
after 'deploy:updating', 'composer:install'
|
21
24
|
after 'deploy:updating', 'magento:patches:apply'
|
22
25
|
after 'deploy:updating', 'magento:setup:permissions'
|
23
26
|
|
24
|
-
before 'deploy:updated', 'slack:deploying'
|
25
27
|
before 'deploy:updated', 'db:backup'
|
28
|
+
before 'deploy:updated', 'magento:cron:remove'
|
26
29
|
before 'deploy:updated', 'sozo:config:setup'
|
27
|
-
before 'deploy:updated', 'magento:maintenance:enable'
|
28
30
|
|
31
|
+
after 'deploy:updated', 'slack:deploying'
|
32
|
+
after 'deploy:updated', 'magento:maintenance:enable'
|
29
33
|
after 'deploy:updated', 'provision:setup_dir'
|
30
34
|
after 'deploy:updated', 'magento:setup:upgrade'
|
31
35
|
after 'deploy:updated', 'magento:setup:di:compile'
|
@@ -39,16 +43,19 @@ after 'deploy:finishing', 'wordpress:cleanup'
|
|
39
43
|
after 'deploy:finishing', 'sozo:optimise'
|
40
44
|
after 'deploy:finishing', 'server:service:restart'
|
41
45
|
after 'deploy:finishing', 'magento:maintenance:disable'
|
46
|
+
after 'deploy:finishing', 'magento:cron:install'
|
42
47
|
|
43
48
|
after 'deploy:finished', "slack:deployed"
|
44
49
|
after 'deploy:finished', "db:cleanup"
|
45
50
|
|
46
51
|
after 'deploy:failed', "sozo:fix_current"
|
47
52
|
after 'deploy:failed', "slack:failed"
|
53
|
+
after 'deploy:failed', 'magento:cron:remove'
|
54
|
+
after 'deploy:failed', 'magento:cron:install'
|
48
55
|
after 'deploy:failed', 'magento:maintenance:disable'
|
49
56
|
|
50
57
|
namespace :load do
|
51
58
|
task :defaults do
|
52
59
|
load 'capistrano/sozo_magento2/defaults.rb'
|
53
60
|
end
|
54
|
-
end
|
61
|
+
end
|
@@ -28,7 +28,7 @@ namespace :db do
|
|
28
28
|
task :wp_db_backup do
|
29
29
|
# Backup the database with a timestamp
|
30
30
|
on roles :all do
|
31
|
-
if (fetch(:wp_backup) == "true")
|
31
|
+
if (fetch(:wp_backup).to_s == "true")
|
32
32
|
info "Backing up WordPress database."
|
33
33
|
execute :n98magerun, 'db:dump', "--root-dir='#{fetch(:mage_root)}'",
|
34
34
|
'--compression="gzip"',
|
@@ -7,6 +7,14 @@ namespace :deploy do
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
after :updated, :confirm_setup do
|
11
|
+
if fetch(:magento_deploy_confirm_roles).include? fetch(:stage).to_s
|
12
|
+
print "\e[0;31m Put site in maintenance mode and deploy to #{fetch(:stage).to_s}? [y/n] \e[0m"
|
13
|
+
proceed = STDIN.gets[0..0] rescue nil
|
14
|
+
exit unless proceed == 'y' || proceed == 'Y'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
10
18
|
|
11
19
|
Rake::Task["cleanup"].clear_actions
|
12
20
|
|
@@ -40,10 +48,15 @@ namespace :deploy do
|
|
40
48
|
desc "Failed deployment tasks"
|
41
49
|
task :failed do
|
42
50
|
on release_roles :all do |host|
|
43
|
-
|
44
|
-
|
51
|
+
if (fetch(:clear_failures) == "true")
|
52
|
+
# Hold for a few seconds to make sure all disk related actions have completed
|
53
|
+
info "Waiting for file / disk writing to complete"
|
54
|
+
sleep(3)
|
55
|
+
# Added sudo to make sure we can clear everything
|
56
|
+
info "Removing failed deployment"
|
57
|
+
execute :sudo, 'rm', '-rf', release_path
|
45
58
|
info "Removed failed deployment"
|
46
59
|
end
|
47
60
|
end
|
48
61
|
end
|
49
|
-
end
|
62
|
+
end
|
@@ -1,5 +1,31 @@
|
|
1
1
|
namespace :magento do
|
2
2
|
|
3
|
+
namespace :cron do
|
4
|
+
desc 'Remove cron'
|
5
|
+
task :remove do
|
6
|
+
on release_roles :all do
|
7
|
+
info "Disabling cron"
|
8
|
+
if (fetch(:handle_cron).to_s == "true")
|
9
|
+
execute :php, '-f', "#{fetch(:deploy_root)}/magento2/bin/magento", 'cron:remove'
|
10
|
+
else
|
11
|
+
info "Cron not controlled by capistrano"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Install cron'
|
17
|
+
task :install do
|
18
|
+
on release_roles :all do
|
19
|
+
info "Enabling cron"
|
20
|
+
if (fetch(:handle_cron).to_s == "true")
|
21
|
+
execute :php, '-f', "#{fetch(:deploy_root)}/magento2/bin/magento", 'cron:install', '-d'
|
22
|
+
else
|
23
|
+
info "Cron not controlled by capistrano"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
3
29
|
namespace :cache do
|
4
30
|
desc 'Flush Magento cache storage'
|
5
31
|
task :flush do
|
@@ -195,22 +221,14 @@ namespace :magento do
|
|
195
221
|
desc 'Enable maintenance mode'
|
196
222
|
task :enable do
|
197
223
|
on release_roles :all do
|
198
|
-
|
199
|
-
if File.exist?("magento/bin/magento")
|
200
|
-
execute :php, '-f', 'magento/bin/magento', 'maintenance:enable'
|
201
|
-
end
|
202
|
-
end
|
224
|
+
execute :php, '-f', "#{fetch(:deploy_root)}/magento2/bin/magento", 'maintenance:enable'
|
203
225
|
end
|
204
226
|
end
|
205
227
|
|
206
228
|
desc 'Disable maintenance mode'
|
207
229
|
task :disable do
|
208
230
|
on release_roles :all do
|
209
|
-
|
210
|
-
if File.exist?("magento/bin/magento")
|
211
|
-
execute :php, '-f', 'magento/bin/magento', 'maintenance:disable'
|
212
|
-
end
|
213
|
-
end
|
231
|
+
execute :php, '-f', "#{fetch(:deploy_root)}/magento2/bin/magento", 'maintenance:disable'
|
214
232
|
end
|
215
233
|
end
|
216
234
|
|
@@ -1,5 +1,32 @@
|
|
1
|
+
require 'capistrano/sozo_magento2/info'
|
2
|
+
|
3
|
+
include SozoMagento2::Info
|
4
|
+
|
1
5
|
namespace :sozo do
|
2
6
|
|
7
|
+
desc "Info"
|
8
|
+
task :info do
|
9
|
+
on roles(:all) do
|
10
|
+
SozoMagento2::Info::Info.new.call
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
namespace :git do
|
15
|
+
desc "Git branch Check"
|
16
|
+
task :check do
|
17
|
+
on roles(:all) do
|
18
|
+
check = capture(:git, 'ls-remote', '--heads', fetch(:repo_url), fetch(:branch), '|', 'wc', '-l')
|
19
|
+
|
20
|
+
if check.to_i == 1
|
21
|
+
info "Branch is available for deployment."
|
22
|
+
else
|
23
|
+
error "Branch does not exist in git repository, have you pushed your changes?"
|
24
|
+
exit 1
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
3
30
|
desc "Fix current directory if needed"
|
4
31
|
task :fix_current do
|
5
32
|
on roles(:all) do
|
@@ -64,7 +91,6 @@ namespace :sozo do
|
|
64
91
|
end
|
65
92
|
on roles :production do
|
66
93
|
within release_path do
|
67
|
-
invoke 'magento:cache:enable'
|
68
94
|
invoke 'magento:cache:flush'
|
69
95
|
invoke 'magento:indexer:reindex'
|
70
96
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-sozo_magento2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clive Walkden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -32,6 +32,7 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- ".gitignore"
|
35
|
+
- ".yardopts"
|
35
36
|
- BUILD.md
|
36
37
|
- CHANGELOG.md
|
37
38
|
- Gemfile
|
@@ -40,6 +41,7 @@ files:
|
|
40
41
|
- capistrano-sozo_magento.gemspec
|
41
42
|
- lib/capistrano/sozo_magento2.rb
|
42
43
|
- lib/capistrano/sozo_magento2/defaults.rb
|
44
|
+
- lib/capistrano/sozo_magento2/info.rb
|
43
45
|
- lib/capistrano/sozo_magento2/slack.rb
|
44
46
|
- lib/capistrano/sozo_magento2/version.rb
|
45
47
|
- lib/capistrano/tasks/composer.rake
|