capistrano-sozo_magento2 1.1.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 067f69be7940139b39853f161c2cdccfaf59bc3efe7c889a3c4282b7a6c91191
4
- data.tar.gz: b235fcf83c747dcdb843e64bdddd44df30366bdc84a363a90e0425571b8a04f4
3
+ metadata.gz: 1b1790fdeb92ff66403be9ccd3f3977ad51383a401deeb09d073e927f1dff17f
4
+ data.tar.gz: 38e34911ea738869e55fe0d0fe5b5e6baad4207a7af91fbbbcae8a615f1b6208
5
5
  SHA512:
6
- metadata.gz: 4015c5c7f9cf4be49d35cda7732803d4e7bd240c7d4b5f85470c8a05587c452fcb48452509561b9d55ef3fa0330ce41582c63f965e427addc5590001c64f9360
7
- data.tar.gz: 60fc48f2e8a1b5437749978e887eec9d7ff28601a27742199826ba9a60101931ace0b6bed9ed44d91858561b79c6bd90c1fe52eb7e0989efbcc47668ae984f35
6
+ metadata.gz: 81a868673b25d2ee710b90dba9be7b478b48dbe80b5c238dcdbe493e6255d6647202b619b6bb0c9d71c2c34632d7757450252193e1f218e571dba14dd3dd9e00
7
+ data.tar.gz: 3125ca35d6f5e0b0ef62cf3283fdf9f97935e5ff3a56268ac8c52c231ff7c36459084f9d72a174a5b60b073a9dd9fe557250e4d81bcede40f30852d38e688547
data/CHANGELOG.md CHANGED
@@ -21,7 +21,43 @@ Given a version number MAJOR.MINOR.PATCH, increment the:
21
21
 
22
22
  ## [Unreleased]
23
23
 
24
- ## [v1.1.0] - 2020-02-24
24
+
25
+ ## [v1.3.1] - 2021-07-29
26
+ ### Changed
27
+ - Changed ENV options for WordPress plugins and themes removal.
28
+ - Multi-PHP support via ability to pass PHP version via the command map.
29
+
30
+
31
+ ## [v1.3.0] - 2021-05-14
32
+ ### Added
33
+ - New task to check for ece-patches file `.magento.env.yaml` and to apply if it finds one.
34
+
35
+
36
+ ## [v1.2.1] - 2021-05-06
37
+ ### Fixed
38
+ - WordPress backup not respecting the :wp_backup false option
39
+ - Erroneous symlink created inside release directories
40
+ - Added simple text output in Slack message
41
+
42
+
43
+ ## [v1.2.0] - 2021-03-25
44
+ ### Added
45
+ - New variable `clear_failures` for future use.
46
+ - New Slack class to control the message template.
47
+
48
+ ### Changed
49
+ - Updated Slack messaging to newer version to future proof.
50
+ - Current directory fix now updates MAGE_ROOT as well.
51
+ - Standardised tasks order based on key capistrano core tasks.
52
+
53
+ ### Removed
54
+ - Removed dotenv from the gem.
55
+
56
+ ### Fixed
57
+ - Fix issue when there were less than CAP_KEEP_BACKUPS available.
58
+
59
+
60
+ ## [v1.1.0] - 2021-02-24
25
61
  ### Added
26
62
  - Added defaults for the :wp_backup, :keep_backups and :slack_channel instead of using ENV's
27
63
  - Added BUILD.md for reminders on how to build and publish the gem.
@@ -37,7 +73,7 @@ Given a version number MAJOR.MINOR.PATCH, increment the:
37
73
  - Confirm command now using correct symbols to display against roles.
38
74
 
39
75
 
40
- ## [v1.0.1] - 2020-02-20
76
+ ## [v1.0.1] - 2021-02-20
41
77
  ### Added
42
78
  - CHANGELOG.md
43
79
  - License text
@@ -47,5 +83,5 @@ Given a version number MAJOR.MINOR.PATCH, increment the:
47
83
  - Documentation references to the gem.
48
84
 
49
85
 
50
- ### [v1.0.0] - 2020-02-20
86
+ ### [v1.0.0] - 2021-02-20
51
87
  - 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.1"
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
 
@@ -17,7 +17,8 @@ Gem::Specification.new do |spec|
17
17
  spec.bindir = "bin"
18
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
+
21
+ spec.required_ruby_version = '>= 2.5.3'
20
22
 
21
23
  spec.add_dependency "capistrano", "~> 3.9"
22
- spec.add_dependency "dotenv", "~> 2.2"
23
24
  end
@@ -1,10 +1,9 @@
1
1
  require 'date'
2
- require 'dotenv'
3
- Dotenv.load
4
2
 
5
- SSHKit.config.command_map[:composer] = 'php -dmemory_limit=-1 -f /usr/local/bin/composer'
6
- SSHKit.config.command_map[:n98magerun] = '/usr/local/bin/n98-magerun'
7
- 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 --'
8
7
 
9
8
  load File.expand_path('../tasks/sozo_magento2.rake', __FILE__)
10
9
  load File.expand_path('../tasks/deploy.rake', __FILE__)
@@ -19,33 +18,34 @@ load File.expand_path('../tasks/server.rake', __FILE__)
19
18
  load File.expand_path('../tasks/wordpress.rake', __FILE__)
20
19
 
21
20
  after 'deploy:updating', 'composer:install'
22
- after 'composer:install', 'magento:setup:permissions'
21
+ after 'deploy:updating', 'magento:patches:apply'
22
+ after 'deploy:updating', 'magento:setup:permissions'
23
23
 
24
24
  before 'deploy:updated', 'slack:deploying'
25
- after 'slack:deploying', 'db:backup'
26
- after 'db:backup', 'sozo:config:setup'
27
- after 'sozo:config:setup', 'magento:maintenance:enable'
25
+ before 'deploy:updated', 'db:backup'
26
+ before 'deploy:updated', 'sozo:config:setup'
27
+ before 'deploy:updated', 'magento:maintenance:enable'
28
28
 
29
29
  after 'deploy:updated', 'provision:setup_dir'
30
- after 'provision:setup_dir', 'magento:setup:upgrade'
31
- after 'magento:setup:upgrade', 'magento:setup:di:compile'
32
- after 'magento:setup:di:compile', 'magento:setup:static-content:deploy'
33
- after 'magento:setup:static-content:deploy', 'provision:permissions'
30
+ after 'deploy:updated', 'magento:setup:upgrade'
31
+ after 'deploy:updated', 'magento:setup:di:compile'
32
+ after 'deploy:updated', 'magento:setup:static-content:deploy'
33
+ after 'deploy:updated', 'provision:permissions'
34
34
 
35
35
  after 'deploy:finishing', 'sozo:symlink'
36
- after 'sozo:symlink', 'fishpig:setup:install_theme'
37
- after 'fishpig:setup:install_theme', 'wordpress:sozo_mu'
38
- after 'wordpress:sozo_mu', 'wordpress:cleanup'
39
- after 'wordpress:cleanup', 'sozo:optimise'
40
- after 'sozo:optimise', 'server:service:restart'
41
- after 'server:service:restart', 'magento:maintenance:disable'
36
+ after 'deploy:finishing', 'fishpig:setup:install_theme'
37
+ after 'deploy:finishing', 'wordpress:sozo_mu'
38
+ after 'deploy:finishing', 'wordpress:cleanup'
39
+ after 'deploy:finishing', 'sozo:optimise'
40
+ after 'deploy:finishing', 'server:service:restart'
41
+ after 'deploy:finishing', 'magento:maintenance:disable'
42
42
 
43
43
  after 'deploy:finished', "slack:deployed"
44
- after 'slack:deployed', "db:cleanup"
44
+ after 'deploy:finished', "db:cleanup"
45
45
 
46
+ after 'deploy:failed', "sozo:fix_current"
46
47
  after 'deploy:failed', "slack:failed"
47
- after 'slack:failed', "sozo:fix_current"
48
- after 'sozo:fix_current', 'magento:maintenance:disable'
48
+ after 'deploy:failed', 'magento:maintenance:disable'
49
49
 
50
50
  namespace :load do
51
51
  task :defaults do
@@ -27,12 +27,21 @@ 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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'
36
41
 
37
42
  # Deployment defaults
38
- set :magento_deploy_confirm_roles, fetch(:magento_deploy_confirm_roles, [])
43
+ set :magento_deploy_confirm_roles, fetch(:magento_deploy_confirm_roles, [])
44
+
45
+ # Other defaults (for future use)
46
+ # Clear or leave the failed deployment dirs
47
+ set :clear_failures, fetch(:clear_failures, true)
@@ -0,0 +1,65 @@
1
+ require 'json'
2
+
3
+ include Capistrano::DSL
4
+
5
+ module SozoMagento2
6
+ module Slack
7
+ def message_hash
8
+ {
9
+ "channel" => fetch(:slack_channel),
10
+ "username" => "SOZO Deploy Bot",
11
+ "icon_emoji" => ":satellite:",
12
+ "color" => "good",
13
+ "text" => "#{fetch(:url)} Deployment Process Begun",
14
+ "blocks" => [
15
+ {
16
+ "type" => "header",
17
+ "text" => {
18
+ "type" => "plain_text",
19
+ "text" => "Deployment Process Begun"
20
+ }
21
+ },
22
+ {
23
+ "type" => "divider"
24
+ },
25
+ {
26
+ "type" => "section",
27
+ "text" => {
28
+ "type" => "mrkdwn",
29
+ "text" => "#{fetch(:url)} is being Deployed"
30
+ },
31
+ "accessory" => {
32
+ "type" => "button",
33
+ "style" => "primary",
34
+ "text" => {
35
+ "type" => "plain_text",
36
+ "text" => "Visit Site",
37
+ "emoji" => true
38
+ },
39
+ "value" => "click_me_123",
40
+ "url" => fetch(:url),
41
+ "action_id" => "button-action"
42
+ }
43
+ },
44
+ {
45
+ "type" => "section",
46
+ "fields" => [
47
+ {
48
+ "type" => "mrkdwn",
49
+ "text" => "*Branch:*\n#{fetch(:branch)}"
50
+ },
51
+ {
52
+ "type" => "mrkdwn",
53
+ "text" => "*Developer:*\n#{fetch(:local_user)}"
54
+ },
55
+ {
56
+ "type" => "mrkdwn",
57
+ "text" => "*Environment:*\n#{fetch(:environment)}"
58
+ }
59
+ ]
60
+ }
61
+ ]
62
+ }
63
+ end
64
+ end
65
+ end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module SozoMagento2
3
- VERSION = "1.1.0"
3
+ VERSION = "1.3.1"
4
4
  end
5
5
  end
@@ -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) == "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
 
@@ -49,11 +53,11 @@ namespace :db do
49
53
  files = (valid - valid.last(fetch(:keep_backups).to_i)).map do |backup|
50
54
  "#{fetch(:backupdir)}" + "/" + (backup).to_s
51
55
  end
52
- end
53
56
 
54
- if files.any?
55
- files.each_slice(100) do |files_batch|
56
- execute :rm, "-f", *files_batch
57
+ if files.any?
58
+ files.each_slice(100) do |files_batch|
59
+ execute :rm, "-f", *files_batch
60
+ end
57
61
  end
58
62
  end
59
63
  end
@@ -5,7 +5,7 @@ namespace :magento do
5
5
  task :flush do
6
6
  on release_roles :all do
7
7
  within release_path do
8
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'cache:flush'
8
+ execute :php, '-f', 'magento/bin/magento', 'cache:flush'
9
9
  end
10
10
  end
11
11
  end
@@ -14,7 +14,7 @@ namespace :magento do
14
14
  task :clean do
15
15
  on release_roles :all do
16
16
  within release_path do
17
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'cache:clean'
17
+ execute :php, '-f', 'magento/bin/magento', 'cache:clean'
18
18
  end
19
19
  end
20
20
  end
@@ -24,7 +24,7 @@ namespace :magento do
24
24
  on release_roles :all do
25
25
  within release_path do
26
26
  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'
27
+ 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
28
  end
29
29
  end
30
30
  end
@@ -34,7 +34,7 @@ namespace :magento do
34
34
  task :disable do
35
35
  on release_roles :all do
36
36
  within release_path do
37
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'cache:disable'
37
+ execute :php, '-f', 'magento/bin/magento', 'cache:disable'
38
38
  end
39
39
  end
40
40
  end
@@ -43,7 +43,7 @@ namespace :magento do
43
43
  task :status do
44
44
  on release_roles :all do
45
45
  within release_path do
46
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'cache:status'
46
+ execute :php, '-f', 'magento/bin/magento', 'cache:status'
47
47
  end
48
48
  end
49
49
  end
@@ -76,7 +76,7 @@ namespace :magento do
76
76
  if test("[ -f #{release_path}/magento/app/etc/config.php ]")
77
77
  # Exists, carry on
78
78
  else
79
- execute :php, '-dmemory_limit=-1', '-f', 'bin/magento', "module:enable", "--all"
79
+ execute :php, '-f', 'bin/magento', "module:enable", "--all"
80
80
  end
81
81
  end
82
82
  end
@@ -86,7 +86,7 @@ namespace :magento do
86
86
  task 'disable', :module_name do |t, args|
87
87
  on release_roles :staging do
88
88
  within release_path + 'magento/' do
89
- execute :php, '-dmemory_limit=-1', '-f', 'bin/magento', "module:disable", args[:module_name]
89
+ execute :php, '-f', 'bin/magento', "module:disable", args[:module_name]
90
90
  end
91
91
  end
92
92
  end
@@ -95,7 +95,7 @@ namespace :magento do
95
95
  task 'enable', :module_name do |t, args|
96
96
  on release_roles :staging do
97
97
  within release_path + 'magento/' do
98
- execute :php, '-dmemory_limit=-1', '-f', 'bin/magento', "module:enable", args[:module_name], '-f'
98
+ execute :php, '-f', 'bin/magento', "module:enable", args[:module_name], '-f'
99
99
  invoke 'magento:setup:upgrade'
100
100
  invoke 'magento:setup:static-content:deploy'
101
101
  end
@@ -112,7 +112,7 @@ namespace :magento do
112
112
  within release_path + 'magento/' do
113
113
  ask(:parameter, '')
114
114
  ask(:value, '')
115
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', "setup:config:set", "--#{fetch(:parameter)}=#{fetch(:value)}", "--no-interaction"
115
+ execute :php, '-f', 'magento/bin/magento', "setup:config:set", "--#{fetch(:parameter)}=#{fetch(:value)}", "--no-interaction"
116
116
  end
117
117
  end
118
118
  end
@@ -131,7 +131,7 @@ namespace :magento do
131
131
  task :upgrade do
132
132
  on release_roles :all do
133
133
  within release_path do
134
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'setup:upgrade', '-n'
134
+ execute :php, '-f', 'magento/bin/magento', 'setup:upgrade', '-n'
135
135
  end
136
136
  end
137
137
  end
@@ -172,7 +172,7 @@ namespace :magento do
172
172
  task :compile do
173
173
  on release_roles :all do
174
174
  within release_path do
175
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'setup:di:compile'
175
+ execute :php, '-f', 'magento/bin/magento', 'setup:di:compile'
176
176
  end
177
177
  end
178
178
  end
@@ -183,7 +183,7 @@ namespace :magento do
183
183
  task :deploy do
184
184
  on release_roles :all do
185
185
  within release_path do
186
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'setup:static-content:deploy -f en_US en_GB -j6'
186
+ execute :php, '-f', 'magento/bin/magento', 'setup:static-content:deploy -f en_US en_GB -j6'
187
187
  end
188
188
  end
189
189
  end
@@ -197,7 +197,7 @@ namespace :magento do
197
197
  on release_roles :all do
198
198
  within current_path do
199
199
  if File.exist?("magento/bin/magento")
200
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'maintenance:enable'
200
+ execute :php, '-f', 'magento/bin/magento', 'maintenance:enable'
201
201
  end
202
202
  end
203
203
  end
@@ -208,7 +208,7 @@ namespace :magento do
208
208
  on release_roles :all do
209
209
  within current_path do
210
210
  if File.exist?("magento/bin/magento")
211
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'maintenance:disable'
211
+ execute :php, '-f', 'magento/bin/magento', 'maintenance:disable'
212
212
  end
213
213
  end
214
214
  end
@@ -218,7 +218,7 @@ namespace :magento do
218
218
  task :status do
219
219
  on release_roles :all do
220
220
  within current_path do
221
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'maintenance:status'
221
+ execute :php, '-f', 'magento/bin/magento', 'maintenance:status'
222
222
  end
223
223
  end
224
224
  end
@@ -227,7 +227,7 @@ namespace :magento do
227
227
  task 'allow-ips', :ip do |t, args|
228
228
  on release_roles :all do
229
229
  within current_path do
230
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'maintenance:allow-ips', args[:ip]
230
+ execute :php, '-f', 'magento/bin/magento', 'maintenance:allow-ips', args[:ip]
231
231
  end
232
232
  end
233
233
  end
@@ -238,7 +238,37 @@ namespace :magento do
238
238
  task :reindex do
239
239
  on release_roles :all do
240
240
  within release_path do
241
- execute :php, '-dmemory_limit=-1', '-f', 'magento/bin/magento', 'indexer:reindex'
241
+ execute :php, '-f', 'magento/bin/magento', 'indexer:reindex'
242
+ end
243
+ end
244
+ end
245
+ end
246
+
247
+ namespace :patches do
248
+ desc 'Run the ece-patch tool if the .magento.env.yaml file exists'
249
+ task :apply do
250
+ on release_roles :all do
251
+ within release_path do
252
+ if test("[ -f #{release_path}/magento/.magento.env.yaml ]")
253
+ info 'Applying patches'
254
+ execute :php, '-f', 'magento/vendor/bin/ece-patches', 'apply --no-interaction'
255
+ else
256
+ info 'No patch file found, skipping.'
257
+ end
258
+ end
259
+ end
260
+ end
261
+
262
+ desc 'Revert patches if the .magento.env.yaml files exists'
263
+ task :revert do
264
+ on release_roles :all do
265
+ within release_path do
266
+ if test("[ -f #{release_path}/magento/.magento.env.yaml ]")
267
+ info 'Reverting patches'
268
+ execute :php, '-f', 'magento/vendor/bin/ece-patches', 'revert --no-interaction'
269
+ else
270
+ info 'No patch file found, skipping.'
271
+ end
242
272
  end
243
273
  end
244
274
  end
@@ -1,29 +1,49 @@
1
+ require 'capistrano/sozo_magento2/slack'
2
+
3
+ include SozoMagento2::Slack
4
+
1
5
  namespace :slack do
2
6
  desc "Post to channel that the site has been deployed"
3
7
  task :deployed do
4
8
  on roles(:all) do
5
- execute :curl, "-X", "POST", "--data-urlencode", "'payload={\"channel\": \"#{fetch(:slack_channel)}\", \"username\": \"SOZO Deploy Bot\", \"pretext\": \"Deployment Successful\", \"text\": \"<#{fetch(:url)}> Deployed\", \"icon_emoji\": \":satellite:\", \"color\": \"good\", \"fields\": [{ \"title\": \"Branch\", \"value\": \"#{fetch(:branch)}\", \"short\": \"true\" },{ \"title\": \"Environment\", \"value\": \"#{fetch(:environment)}\", \"short\": \"true\" }]}'", "#{fetch(:slack_webhook)}"
9
+ slack_template = message_hash
10
+ slack_template['text'] = "#{fetch(:url)} Deployment Process Successful"
11
+ slack_template['blocks'][0]['text']['text'] = ":smile: Deployment Successful :smile:"
12
+ slack_template['blocks'][2]['text']['text'] = "#{fetch(:url)} Deployed."
13
+ execute :curl, "--request", "POST", "--header", "'Content-Type: application/json'", "--data", "'" + JSON.generate(slack_template) + "'", fetch(:slack_webhook)
6
14
  end
7
15
  end
8
16
 
9
17
  desc "Post to channel that the site is being deployed"
10
18
  task :deploying do
11
19
  on roles(:all) do
12
- execute :curl, "-X", "POST", "--data-urlencode", "'payload={\"channel\": \"#{fetch(:slack_channel)}\", \"username\": \"SOZO Deploy Bot\", \"pretext\": \"Deployment Process Begun\", \"text\": \"<#{fetch(:url)}> is being Deployed\", \"icon_emoji\": \":satellite:\", \"color\": \"warning\", \"fields\": [{ \"title\": \"Branch\", \"value\": \"#{fetch(:branch)}\", \"short\": \"true\" },{ \"title\": \"Environment\", \"value\": \"#{fetch(:environment)}\", \"short\": \"true\" }]}'", "#{fetch(:slack_webhook)}"
20
+ slack_template = message_hash
21
+ slack_template['text'] = "#{fetch(:url)} Deployment Process Begun"
22
+ slack_template['blocks'][0]['text']['text'] = ":crossed_fingers: Deployment Process Begun :crossed_fingers:"
23
+ slack_template['blocks'][2]['text']['text'] = "#{fetch(:url)} is being Deployed."
24
+ execute :curl, "--request", "POST", "--header", "'Content-Type: application/json'", "--data", "'" + JSON.generate(slack_template) + "'", fetch(:slack_webhook)
13
25
  end
14
26
  end
15
27
 
16
28
  desc "Post to channel that something is happening"
17
29
  task :message do
18
30
  on roles(:all) do
19
- execute :curl, "-X", "POST", "--data-urlencode", "'payload={\"channel\": \"#{fetch(:slack_channel)}\", \"username\": \"SOZO Deploy Bot\", \"pretext\": \"Next stage\", \"text\": \"<#{fetch(:url)}> is stage change\", \"icon_emoji\": \":satellite:\", \"color\": \"good\", \"fields\": [{ \"title\": \"Branch\", \"value\": \"#{fetch(:branch)}\", \"short\": \"true\" },{ \"title\": \"Environment\", \"value\": \"#{fetch(:environment)}\", \"short\": \"true\" }]}'", "#{fetch(:slack_webhook)}"
31
+ slack_template = message_hash
32
+ slack_template['text'] = "Some message here"
33
+ slack_template['blocks'][0]['text']['text'] = "Message"
34
+ slack_template['blocks'][2]['text']['text'] = "Some message to go here"
35
+ execute :curl, "--request", "POST", "--header", "'Content-Type: application/json'", "--data", "'" + JSON.generate(slack_template) + "'", fetch(:slack_webhook)
20
36
  end
21
37
  end
22
38
 
23
39
  desc "Post to channel that the site deployment has failed"
24
40
  task :failed do
25
41
  on roles(:all) do
26
- execute :curl, "-X", "POST", "--data-urlencode", "'payload={\"channel\": \"#{fetch(:slack_channel)}\", \"username\": \"SOZO Deploy Bot\", \"pretext\": \"Deployment Process Failed\", \"text\": \"<#{fetch(:url)}> deployment has failed\", \"icon_emoji\": \":satellite:\", \"color\": \"warning\", \"fields\": [{ \"title\": \"Branch\", \"value\": \"#{fetch(:branch)}\", \"short\": \"true\" },{ \"title\": \"Environment\", \"value\": \"#{fetch(:environment)}\", \"short\": \"true\" }]}'", "#{fetch(:slack_webhook)}"
42
+ slack_template = message_hash
43
+ slack_template['text'] = "#{fetch(:url)} Deployment Process Failed!"
44
+ slack_template['blocks'][0]['text']['text'] = ":boom: Deployment Process Failed :boom:"
45
+ slack_template['blocks'][2]['text']['text'] = "#{fetch(:url)} deployment has failed."
46
+ execute :curl, "--request", "POST", "--header", "'Content-Type: application/json'", "--data", "'" + JSON.generate(slack_template) + "'", fetch(:slack_webhook)
27
47
  end
28
48
  end
29
49
  end
@@ -6,10 +6,19 @@ namespace :sozo do
6
6
  releases = capture(:ls, "-x", releases_path).split
7
7
  valid, invalid = releases.partition { |e| /^\d{14}$/ =~ e }
8
8
 
9
- info "last release #{valid.last}"
10
- info "Creating symlink from #{fetch(:deploy_to)}/releases/#{valid.last} to #{fetch(:deploy_to)}/current"
9
+ info "Checking current and magento root directories are setup correctly."
11
10
 
12
- execute :ln, "-sf", "#{fetch(:deploy_to)}/releases/#{valid.last}", "#{fetch(:deploy_to)}/current"
11
+ current = "#{fetch(:deploy_to)}/current"
12
+ if test("[ ! -e #{current} ]")
13
+ info "Current link #{current} link is broken, regenerating."
14
+ execute :ln, "-sf", "#{fetch(:deploy_to)}/releases/#{valid.last}", current
15
+ end
16
+
17
+ m2root = "#{fetch(:mage_root)}"
18
+ if test("[ ! -e #{m2root} ]")
19
+ info "M2Path link #{m2root} link is broken, regenerating."
20
+ execute :ln, "-sf", "#{fetch(:deploy_to)}/releases/#{valid.last}/magento", m2root
21
+ end
13
22
  end
14
23
  end
15
24
 
@@ -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.1.0
4
+ version: 1.3.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: 2021-02-24 00:00:00.000000000 Z
11
+ date: 2021-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.9'
27
- - !ruby/object:Gem::Dependency
28
- name: dotenv
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '2.2'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '2.2'
41
27
  description: Magento 2 support for Capistrano 3.x in SOZO hosted environments
42
28
  email:
43
29
  - clive@sozodesign.co.uk
@@ -54,6 +40,7 @@ files:
54
40
  - capistrano-sozo_magento.gemspec
55
41
  - lib/capistrano/sozo_magento2.rb
56
42
  - lib/capistrano/sozo_magento2/defaults.rb
43
+ - lib/capistrano/sozo_magento2/slack.rb
57
44
  - lib/capistrano/sozo_magento2/version.rb
58
45
  - lib/capistrano/tasks/composer.rake
59
46
  - lib/capistrano/tasks/db.rake
@@ -78,7 +65,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
65
  requirements:
79
66
  - - ">="
80
67
  - !ruby/object:Gem::Version
81
- version: '0'
68
+ version: 2.5.3
82
69
  required_rubygems_version: !ruby/object:Gem::Requirement
83
70
  requirements:
84
71
  - - ">="