capistrano-sozo_magento2 1.2.0 → 1.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57d66531993d668be8a75fef480862d07035dcf0750f7831912f71bc749d5201
4
- data.tar.gz: 5032e4073c3eed84ce9030206c0e9c3cfbdfbf29e8d12d1968802f48df3fa42b
3
+ metadata.gz: ab55bf423e1766857aeff0a542b1b2657e35a6401d7dda6469404df07060d90c
4
+ data.tar.gz: 43a54ea1407c899c1f9545c6cb6703977ac70690053f6efdd61d18024eb933dd
5
5
  SHA512:
6
- metadata.gz: 3550c64e691e692c9e896078f269ecc8ef5035b3ce4c110df0020aa47cdd6d6c5e3b1bb47b58f06ef57db16b57a96510d6ac8509713fd3ff4f299519810842f1
7
- data.tar.gz: 2e6f979c104a3c2d175894d0cc3e0ad08531abdc9bbfb8faa19cc2714c4d0e92bf18a2c2c6fa042f7a30a8228842167ea44ece6350482a4d886d2e344fedce98
6
+ metadata.gz: 0d068c92ebcd093a49b7ca63685a0d27e898aa3884d5ecd9a5ea9b7c339eae83c700eccaab3b5ac959b2c12d20cfae7d7526376365045996e8d88e5a38802dff
7
+ data.tar.gz: 42b84543c461b955f32cff824750a12b06ed8de464c5b6227915440b28f732a3d22355a0066bd38c45f425b16c58ecaa11e4d7ea6f40cbd7d078f15a5d5e39dd
data/.yardopts ADDED
@@ -0,0 +1,5 @@
1
+ --protected
2
+ --no-private
3
+ -
4
+ CHANGELOG.md
5
+ LICENSE
data/CHANGELOG.md CHANGED
@@ -21,7 +21,40 @@ Given a version number MAJOR.MINOR.PATCH, increment the:
21
21
 
22
22
  ## [Unreleased]
23
23
 
24
- ## [v1.2.0] - 2020-03-25
24
+
25
+ ## [v1.4.0] - 2021-08-03
26
+ ### Added
27
+ - New `deploy:check` info output with key information displayed.
28
+ - Magento Cron control now included in the deployment methods with `:handle_cron` option (default false).
29
+ - New check `sozo:git:check` to see if the branch exists in the repository before deployment begins.
30
+ - Documented code with Yardoc
31
+
32
+ ### Changed
33
+ - Delay added (3 seconds) before trying to delete a failed deployment to allow file or disk activity to finish.
34
+ - Added sudo to failed deployments release deleting.
35
+ - Changed maintenance mode path to use the `deploy_root` location from `current_path`
36
+ - Checked all boolean values against string "true" or "false" using .to_s == 'true'
37
+
38
+
39
+ ## [v1.3.1] - 2021-07-29
40
+ ### Changed
41
+ - Changed ENV options for WordPress plugins and themes removal.
42
+ - Multi-PHP support via ability to pass PHP version via the command map.
43
+
44
+
45
+ ## [v1.3.0] - 2021-05-14
46
+ ### Added
47
+ - New task to check for ece-patches file `.magento.env.yaml` and to apply if it finds one.
48
+
49
+
50
+ ## [v1.2.1] - 2021-05-06
51
+ ### Fixed
52
+ - WordPress backup not respecting the :wp_backup false option
53
+ - Erroneous symlink created inside release directories
54
+ - Added simple text output in Slack message
55
+
56
+
57
+ ## [v1.2.0] - 2021-03-25
25
58
  ### Added
26
59
  - New variable `clear_failures` for future use.
27
60
  - New Slack class to control the message template.
@@ -38,7 +71,7 @@ Given a version number MAJOR.MINOR.PATCH, increment the:
38
71
  - Fix issue when there were less than CAP_KEEP_BACKUPS available.
39
72
 
40
73
 
41
- ## [v1.1.0] - 2020-02-24
74
+ ## [v1.1.0] - 2021-02-24
42
75
  ### Added
43
76
  - Added defaults for the :wp_backup, :keep_backups and :slack_channel instead of using ENV's
44
77
  - Added BUILD.md for reminders on how to build and publish the gem.
@@ -54,7 +87,7 @@ Given a version number MAJOR.MINOR.PATCH, increment the:
54
87
  - Confirm command now using correct symbols to display against roles.
55
88
 
56
89
 
57
- ## [v1.0.1] - 2020-02-20
90
+ ## [v1.0.1] - 2021-02-20
58
91
  ### Added
59
92
  - CHANGELOG.md
60
93
  - License text
@@ -64,5 +97,5 @@ Given a version number MAJOR.MINOR.PATCH, increment the:
64
97
  - Documentation references to the gem.
65
98
 
66
99
 
67
- ### [v1.0.0] - 2020-02-20
100
+ ### [v1.0.0] - 2021-02-20
68
101
  - Initial release
data/README.md CHANGED
@@ -7,7 +7,7 @@ It is advised to use bundler.
7
7
 
8
8
  1. Add the following to your projects `Gemfile`
9
9
  ```
10
- gem "capistrano-sozo_magento2", "~> 1.2"
10
+ gem "capistrano-sozo_magento2", "~> 1.3"
11
11
  ```
12
12
  2. Install
13
13
  ```
@@ -62,6 +62,20 @@ If you would like to customize the linked files or directories for your project,
62
62
  append :linked_dirs, 'path/to/link'
63
63
  ```
64
64
 
65
+ ## Command Mapping
66
+ The module assumes the following bin files are in the following locations:
67
+ 1. `php` in your path accessible from the command line as php
68
+ 2. `composer` in `/usr/local/bin/composer`
69
+ 3. `n98-magerun` in `/usr/local/bin/n98-magerun`
70
+
71
+ Composer and n98-magerun command are both prefixed with the PHP path (for multi-php support), if you are overwriting these commands via the command map you will need to include the php bin in your `stage.rb` file similar to the following.
72
+ ```
73
+ SSHKit.config.command_map[:php] = '/usr/bin/env php74 -dmemory_limit=-1'
74
+ SSHKit.config.command_map[:composer] = SSHKit.config.command_map[:php], '-f /usr/local/bin/composer'
75
+ SSHKit.config.command_map[:n98magerun] = SSHKit.config.command_map[:php], '-f /usr/local/bin/n98-magerun'
76
+ SSHKit.config.command_map[:magento] = SSHKit.config.command_map[:php], '-f bin/magento --'
77
+ ```
78
+
65
79
  ## Versioning
66
80
  We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/sozo-design/capistrano-sozo-magento2/tags) or [CHANGELOG.md](./CHANGELOG.md).
67
81
 
@@ -1,8 +1,9 @@
1
1
  require 'date'
2
2
 
3
- SSHKit.config.command_map[:composer] = 'php -dmemory_limit=-1 -f /usr/local/bin/composer'
4
- SSHKit.config.command_map[:n98magerun] = '/usr/local/bin/n98-magerun'
5
- SSHKit.config.command_map[:magento] = "/usr/bin/env php -d memory_limit=1G -f bin/magento --"
3
+ SSHKit.config.command_map[:php] = '/usr/bin/env php -dmemory_limit=-1'
4
+ SSHKit.config.command_map[:composer] = SSHKit.config.command_map[:php], '-f /usr/local/bin/composer'
5
+ SSHKit.config.command_map[:n98magerun] = SSHKit.config.command_map[:php], '-f /usr/local/bin/n98-magerun'
6
+ SSHKit.config.command_map[:magento] = SSHKit.config.command_map[:php], '-f bin/magento --'
6
7
 
7
8
  load File.expand_path('../tasks/sozo_magento2.rake', __FILE__)
8
9
  load File.expand_path('../tasks/deploy.rake', __FILE__)
@@ -16,11 +17,16 @@ load File.expand_path('../tasks/provision.rake', __FILE__)
16
17
  load File.expand_path('../tasks/server.rake', __FILE__)
17
18
  load File.expand_path('../tasks/wordpress.rake', __FILE__)
18
19
 
20
+ after 'deploy:check', 'sozo:git:check'
21
+ after 'deploy:check', 'sozo:info'
22
+
19
23
  after 'deploy:updating', 'composer:install'
24
+ after 'deploy:updating', 'magento:patches:apply'
20
25
  after 'deploy:updating', 'magento:setup:permissions'
21
26
 
22
27
  before 'deploy:updated', 'slack:deploying'
23
28
  before 'deploy:updated', 'db:backup'
29
+ before 'deploy:updated', 'magento:cron:remove'
24
30
  before 'deploy:updated', 'sozo:config:setup'
25
31
  before 'deploy:updated', 'magento:maintenance:enable'
26
32
 
@@ -37,12 +43,15 @@ after 'deploy:finishing', 'wordpress:cleanup'
37
43
  after 'deploy:finishing', 'sozo:optimise'
38
44
  after 'deploy:finishing', 'server:service:restart'
39
45
  after 'deploy:finishing', 'magento:maintenance:disable'
46
+ after 'deploy:finishing', 'magento:cron:install'
40
47
 
41
48
  after 'deploy:finished', "slack:deployed"
42
49
  after 'deploy:finished', "db:cleanup"
43
50
 
44
- after 'deploy:failed', "slack:failed"
45
51
  after 'deploy:failed', "sozo:fix_current"
52
+ after 'deploy:failed', "slack:failed"
53
+ after 'deploy:failed', 'magento:cron:remove'
54
+ after 'deploy:failed', 'magento:cron:install'
46
55
  after 'deploy:failed', 'magento:maintenance:disable'
47
56
 
48
57
  namespace :load do
@@ -27,9 +27,14 @@ set :composer_require_dev_flags, '--optimize-autoloader --prefer-dist'
27
27
  set :date_path, Time.now.strftime("%Y%m%d%H%M%S")
28
28
  set :backupdir, ->{ "#{fetch(:deploy_root)}/backups" }
29
29
  set :backupdirdate, ->{ "#{fetch(:backupdir)}/#{fetch(:date_path)}" }
30
- set :wp_backup, fetch(:wp_backup, true)
31
30
  set :keep_backups, fetch(:keep_backups, 10)
32
31
 
32
+ # WordPress integration defaults
33
+ set :wp_backup, fetch(:wp_backup, true)
34
+ set :wp_delete_themes, fetch(:wp_delete_themes, 'twentyseventeen twentynineteen twentytwenty')
35
+ set :wp_delete_plugins, fetch(:wp_delete_plugins, 'hello')
36
+ set :wp_disable_plugins, fetch(:wp_disable_plugins, '')
37
+
33
38
  # Slack defaults
34
39
  set :slack_channel, fetch(:slack_channel, '#deployments')
35
40
  set :slack_webhook, 'https://hooks.slack.com/services/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'
@@ -37,6 +42,9 @@ set :slack_webhook, 'https://hooks.slack.com/services/T06K8GR2L/
37
42
  # Deployment defaults
38
43
  set :magento_deploy_confirm_roles, fetch(:magento_deploy_confirm_roles, [])
39
44
 
45
+ # Handle removing and installing of cron tasks?
46
+ set :handle_cron, fetch(:handle_cron, false)
47
+
40
48
  # Other defaults (for future use)
41
49
  # Clear or leave the failed deployment dirs
42
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,14 +2,19 @@ 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),
10
14
  "username" => "SOZO Deploy Bot",
11
15
  "icon_emoji" => ":satellite:",
12
16
  "color" => "good",
17
+ "text" => "#{fetch(:url)} Deployment Process Begun",
13
18
  "blocks" => [
14
19
  {
15
20
  "type" => "header",
@@ -1,5 +1,9 @@
1
+ # @author Clive Walkden
1
2
  module Capistrano
3
+ # The plugin version number
2
4
  module SozoMagento2
3
- VERSION = "1.2.0"
5
+ # The plugin version number
6
+ # @return [String] The gem version number
7
+ VERSION = "1.4.0"
4
8
  end
5
9
  end
@@ -1,3 +1,4 @@
1
+ # Composer namespace
1
2
  namespace :composer do
2
3
  desc "Install the Composer dependencies"
3
4
  task :install do
@@ -7,14 +7,14 @@ namespace :db do
7
7
  if test("[ ! -d #{fetch(:backupdir)} ]")
8
8
  execute :mkdir, "-p", fetch(:backupdir)
9
9
  end
10
-
11
- invoke 'db:mag_backup'
12
- invoke 'db:wp_backup' if fetch(:wp_backup)
10
+
11
+ invoke 'db:mag_db_backup'
12
+ invoke 'db:wp_db_backup'
13
13
  end
14
14
  end
15
15
 
16
16
  desc "Backup Magento database"
17
- task :mag_backup do
17
+ task :mag_db_backup do
18
18
  on roles :all do
19
19
  info "Backing up Magento database."
20
20
  execute :n98magerun, 'db:dump', "--root-dir='#{fetch(:mage_root)}'",
@@ -25,14 +25,18 @@ namespace :db do
25
25
  end
26
26
 
27
27
  desc "Backup WordPress database"
28
- task :wp_backup do
28
+ task :wp_db_backup do
29
29
  # Backup the database with a timestamp
30
30
  on roles :all do
31
- info "Backing up WordPress database."
32
- execute :n98magerun, 'db:dump', "--root-dir='#{fetch(:mage_root)}'",
33
- '--compression="gzip"',
34
- '--connection="wordpress"',
35
- '--force', "#{fetch(:backupdir)}/#{fetch(:date_path)}_wp.sql.gz"
31
+ if (fetch(:wp_backup).to_s == "true")
32
+ info "Backing up WordPress database."
33
+ execute :n98magerun, 'db:dump', "--root-dir='#{fetch(:mage_root)}'",
34
+ '--compression="gzip"',
35
+ '--connection="wordpress"',
36
+ '--force', "#{fetch(:backupdir)}/#{fetch(:date_path)}_wp.sql.gz"
37
+ else
38
+ info "WordPress backup set to false"
39
+ end
36
40
  end
37
41
  end
38
42
 
@@ -41,7 +41,12 @@ namespace :deploy do
41
41
  task :failed do
42
42
  on release_roles :all do |host|
43
43
  on roles :production, :staging, :testing do
44
- execute :rm, '-rf', release_path
44
+ # Hold for a few seconds to make sure all disk related actions have completed
45
+ info "Waiting for file / disk writing to complete"
46
+ sleep(3)
47
+ # Added sudo to make sure we can clear everything
48
+ info "Removing failed deployment"
49
+ execute :sudo, 'rm', '-rf', release_path
45
50
  info "Removed failed deployment"
46
51
  end
47
52
  end
@@ -1,11 +1,37 @@
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
6
32
  on release_roles :all do
7
33
  within release_path do
8
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'cache:flush'
34
+ execute :php, '-f', 'magento/bin/magento', 'cache:flush'
9
35
  end
10
36
  end
11
37
  end
@@ -14,7 +40,7 @@ namespace :magento do
14
40
  task :clean do
15
41
  on release_roles :all do
16
42
  within release_path do
17
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'cache:clean'
43
+ execute :php, '-f', 'magento/bin/magento', 'cache:clean'
18
44
  end
19
45
  end
20
46
  end
@@ -24,7 +50,7 @@ namespace :magento do
24
50
  on release_roles :all do
25
51
  within release_path do
26
52
  if File.exist?("magento/bin/magento")
27
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'cache:enable', 'config layout block_html collections reflection db_ddl eav config_integration config_integration_api full_page translate config_webservice'
53
+ execute :php, '-f', 'magento/bin/magento', 'cache:enable', 'config layout block_html collections reflection db_ddl eav config_integration config_integration_api full_page translate config_webservice'
28
54
  end
29
55
  end
30
56
  end
@@ -34,7 +60,7 @@ namespace :magento do
34
60
  task :disable do
35
61
  on release_roles :all do
36
62
  within release_path do
37
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'cache:disable'
63
+ execute :php, '-f', 'magento/bin/magento', 'cache:disable'
38
64
  end
39
65
  end
40
66
  end
@@ -43,7 +69,7 @@ namespace :magento do
43
69
  task :status do
44
70
  on release_roles :all do
45
71
  within release_path do
46
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'cache:status'
72
+ execute :php, '-f', 'magento/bin/magento', 'cache:status'
47
73
  end
48
74
  end
49
75
  end
@@ -76,7 +102,7 @@ namespace :magento do
76
102
  if test("[ -f #{release_path}/magento/app/etc/config.php ]")
77
103
  # Exists, carry on
78
104
  else
79
- execute :php, '-dmemory_limit=-1', '-f', 'bin/magento', "module:enable", "--all"
105
+ execute :php, '-f', 'bin/magento', "module:enable", "--all"
80
106
  end
81
107
  end
82
108
  end
@@ -86,7 +112,7 @@ namespace :magento do
86
112
  task 'disable', :module_name do |t, args|
87
113
  on release_roles :staging do
88
114
  within release_path + 'magento/' do
89
- execute :php, '-dmemory_limit=-1', '-f', 'bin/magento', "module:disable", args[:module_name]
115
+ execute :php, '-f', 'bin/magento', "module:disable", args[:module_name]
90
116
  end
91
117
  end
92
118
  end
@@ -95,7 +121,7 @@ namespace :magento do
95
121
  task 'enable', :module_name do |t, args|
96
122
  on release_roles :staging do
97
123
  within release_path + 'magento/' do
98
- execute :php, '-dmemory_limit=-1', '-f', 'bin/magento', "module:enable", args[:module_name], '-f'
124
+ execute :php, '-f', 'bin/magento', "module:enable", args[:module_name], '-f'
99
125
  invoke 'magento:setup:upgrade'
100
126
  invoke 'magento:setup:static-content:deploy'
101
127
  end
@@ -112,7 +138,7 @@ namespace :magento do
112
138
  within release_path + 'magento/' do
113
139
  ask(:parameter, '')
114
140
  ask(:value, '')
115
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', "setup:config:set", "--#{fetch(:parameter)}=#{fetch(:value)}", "--no-interaction"
141
+ execute :php, '-f', 'magento/bin/magento', "setup:config:set", "--#{fetch(:parameter)}=#{fetch(:value)}", "--no-interaction"
116
142
  end
117
143
  end
118
144
  end
@@ -131,7 +157,7 @@ namespace :magento do
131
157
  task :upgrade do
132
158
  on release_roles :all do
133
159
  within release_path do
134
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'setup:upgrade', '-n'
160
+ execute :php, '-f', 'magento/bin/magento', 'setup:upgrade', '-n'
135
161
  end
136
162
  end
137
163
  end
@@ -172,7 +198,7 @@ namespace :magento do
172
198
  task :compile do
173
199
  on release_roles :all do
174
200
  within release_path do
175
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'setup:di:compile'
201
+ execute :php, '-f', 'magento/bin/magento', 'setup:di:compile'
176
202
  end
177
203
  end
178
204
  end
@@ -183,7 +209,7 @@ namespace :magento do
183
209
  task :deploy do
184
210
  on release_roles :all do
185
211
  within release_path do
186
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'setup:static-content:deploy -f en_US en_GB -j6'
212
+ execute :php, '-f', 'magento/bin/magento', 'setup:static-content:deploy -f en_US en_GB -j6'
187
213
  end
188
214
  end
189
215
  end
@@ -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
- within current_path do
199
- if File.exist?("magento/bin/magento")
200
- execute :php, '-dmemory_limit=-1', '-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
- within current_path do
210
- if File.exist?("magento/bin/magento")
211
- execute :php, '-dmemory_limit=-1', '-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
 
@@ -218,7 +236,7 @@ namespace :magento do
218
236
  task :status do
219
237
  on release_roles :all do
220
238
  within current_path do
221
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'maintenance:status'
239
+ execute :php, '-f', 'magento/bin/magento', 'maintenance:status'
222
240
  end
223
241
  end
224
242
  end
@@ -227,7 +245,7 @@ namespace :magento do
227
245
  task 'allow-ips', :ip do |t, args|
228
246
  on release_roles :all do
229
247
  within current_path do
230
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'maintenance:allow-ips', args[:ip]
248
+ execute :php, '-f', 'magento/bin/magento', 'maintenance:allow-ips', args[:ip]
231
249
  end
232
250
  end
233
251
  end
@@ -238,7 +256,37 @@ namespace :magento do
238
256
  task :reindex do
239
257
  on release_roles :all do
240
258
  within release_path do
241
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'indexer:reindex'
259
+ execute :php, '-f', 'magento/bin/magento', 'indexer:reindex'
260
+ end
261
+ end
262
+ end
263
+ end
264
+
265
+ namespace :patches do
266
+ desc 'Run the ece-patch tool if the .magento.env.yaml file exists'
267
+ task :apply do
268
+ on release_roles :all do
269
+ within release_path do
270
+ if test("[ -f #{release_path}/magento/.magento.env.yaml ]")
271
+ info 'Applying patches'
272
+ execute :php, '-f', 'magento/vendor/bin/ece-patches', 'apply --no-interaction'
273
+ else
274
+ info 'No patch file found, skipping.'
275
+ end
276
+ end
277
+ end
278
+ end
279
+
280
+ desc 'Revert patches if the .magento.env.yaml files exists'
281
+ task :revert do
282
+ on release_roles :all do
283
+ within release_path do
284
+ if test("[ -f #{release_path}/magento/.magento.env.yaml ]")
285
+ info 'Reverting patches'
286
+ execute :php, '-f', 'magento/vendor/bin/ece-patches', 'revert --no-interaction'
287
+ else
288
+ info 'No patch file found, skipping.'
289
+ end
242
290
  end
243
291
  end
244
292
  end
@@ -1,5 +1,4 @@
1
1
  require 'capistrano/sozo_magento2/slack'
2
- require 'json'
3
2
 
4
3
  include SozoMagento2::Slack
5
4
 
@@ -8,6 +7,7 @@ namespace :slack do
8
7
  task :deployed do
9
8
  on roles(:all) do
10
9
  slack_template = message_hash
10
+ slack_template['text'] = "#{fetch(:url)} Deployment Process Successful"
11
11
  slack_template['blocks'][0]['text']['text'] = ":smile: Deployment Successful :smile:"
12
12
  slack_template['blocks'][2]['text']['text'] = "#{fetch(:url)} Deployed."
13
13
  execute :curl, "--request", "POST", "--header", "'Content-Type: application/json'", "--data", "'" + JSON.generate(slack_template) + "'", fetch(:slack_webhook)
@@ -18,6 +18,7 @@ namespace :slack do
18
18
  task :deploying do
19
19
  on roles(:all) do
20
20
  slack_template = message_hash
21
+ slack_template['text'] = "#{fetch(:url)} Deployment Process Begun"
21
22
  slack_template['blocks'][0]['text']['text'] = ":crossed_fingers: Deployment Process Begun :crossed_fingers:"
22
23
  slack_template['blocks'][2]['text']['text'] = "#{fetch(:url)} is being Deployed."
23
24
  execute :curl, "--request", "POST", "--header", "'Content-Type: application/json'", "--data", "'" + JSON.generate(slack_template) + "'", fetch(:slack_webhook)
@@ -28,6 +29,7 @@ namespace :slack do
28
29
  task :message do
29
30
  on roles(:all) do
30
31
  slack_template = message_hash
32
+ slack_template['text'] = "Some message here"
31
33
  slack_template['blocks'][0]['text']['text'] = "Message"
32
34
  slack_template['blocks'][2]['text']['text'] = "Some message to go here"
33
35
  execute :curl, "--request", "POST", "--header", "'Content-Type: application/json'", "--data", "'" + JSON.generate(slack_template) + "'", fetch(:slack_webhook)
@@ -38,6 +40,7 @@ namespace :slack do
38
40
  task :failed do
39
41
  on roles(:all) do
40
42
  slack_template = message_hash
43
+ slack_template['text'] = "#{fetch(:url)} Deployment Process Failed!"
41
44
  slack_template['blocks'][0]['text']['text'] = ":boom: Deployment Process Failed :boom:"
42
45
  slack_template['blocks'][2]['text']['text'] = "#{fetch(:url)} deployment has failed."
43
46
  execute :curl, "--request", "POST", "--header", "'Content-Type: application/json'", "--data", "'" + JSON.generate(slack_template) + "'", fetch(:slack_webhook)
@@ -1,16 +1,51 @@
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
6
33
  releases = capture(:ls, "-x", releases_path).split
7
34
  valid, invalid = releases.partition { |e| /^\d{14}$/ =~ e }
8
35
 
9
- info "last release #{valid.last}"
10
- info "Creating symlink from #{fetch(:deploy_to)}/releases/#{valid.last} to #{fetch(:deploy_to)}/current"
36
+ info "Checking current and magento root directories are setup correctly."
37
+
38
+ current = "#{fetch(:deploy_to)}/current"
39
+ if test("[ ! -e #{current} ]")
40
+ info "Current link #{current} link is broken, regenerating."
41
+ execute :ln, "-sf", "#{fetch(:deploy_to)}/releases/#{valid.last}", current
42
+ end
11
43
 
12
- execute :ln, "-sf", "#{fetch(:deploy_to)}/releases/#{valid.last}", "#{fetch(:deploy_to)}/current"
13
- execute :ln, "-sf", "#{fetch(:deploy_to)}/releases/#{valid.last}", "#{fetch(:mage_root)}"
44
+ m2root = "#{fetch(:mage_root)}"
45
+ if test("[ ! -e #{m2root} ]")
46
+ info "M2Path link #{m2root} link is broken, regenerating."
47
+ execute :ln, "-sf", "#{fetch(:deploy_to)}/releases/#{valid.last}/magento", m2root
48
+ end
14
49
  end
15
50
  end
16
51
 
@@ -56,7 +91,6 @@ namespace :sozo do
56
91
  end
57
92
  on roles :production do
58
93
  within release_path do
59
- invoke 'magento:cache:enable'
60
94
  invoke 'magento:cache:flush'
61
95
  invoke 'magento:indexer:reindex'
62
96
  end
@@ -12,10 +12,15 @@ namespace :wordpress do
12
12
  on roles :all do |host|
13
13
  within release_path + "magento/wp/" do
14
14
  info "Removing default unused WordPress Plugins and Themes"
15
- execute :wp, 'plugin', 'delete', 'hello'
16
- execute :wp, 'theme', 'delete', 'twentyseventeen'
17
- execute :wp, 'theme', 'delete', 'twentynineteen'
18
- execute :wp, 'theme', 'delete', 'twentytwenty'
15
+ if fetch(:wp_disable_plugins).length >= 1
16
+ execute :wp, 'plugin', 'deactivate', fetch(:wp_disable_plugins)
17
+ end
18
+ if fetch(:wp_delete_plugins).length >= 1
19
+ execute :wp, 'plugin', 'delete', fetch(:wp_delete_plugins)
20
+ end
21
+ if fetch(:wp_delete_themes).length >= 1
22
+ execute :wp, 'theme', 'delete', fetch(:wp_delete_themes)
23
+ end
19
24
  execute :rm, '-f', 'readme.html'
20
25
  end
21
26
  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.2.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clive Walkden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-25 00:00:00.000000000 Z
11
+ date: 2021-08-03 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