capistrano-sozo_magento2 1.0.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c002ac19f8884287b44aadbb34cf283f58b3d601482a636f43ad2de645815608
4
- data.tar.gz: c0f0053697d68c11921417d67f0a1ed27a193322be4b2d892db8789c41f9084b
3
+ metadata.gz: 84cc07edb383402a00fb355b8b4b60bcf888916e9b26fb4fe7ba9343532df464
4
+ data.tar.gz: 828a269fcce6b08dd2d1d537e2fd9f1487615bfc2fe91c618217b6f5e9977e0f
5
5
  SHA512:
6
- metadata.gz: 946959dc1c096e3eb3417791c6c9662e450632a16acb08b4119821823692b8531933c0a6c9ad6adaf1131abef3211354a4ebaf06f3610b5a779965d234706259
7
- data.tar.gz: 9075f0fdd973e7bde74ef954dd40220642016219693b910fade75a513279845c512c8421411d49c454d93926efebc24c473c5000b0749f55ae9f44c9fe5f0207
6
+ metadata.gz: 8e60dbae8730826a6d503297040534fe91db718a8e075bd7076eb4779bedb73202b7efafb6ef8bdbb015dd04cf083b839943650dd7524ff7cf130d4547cd11b1
7
+ data.tar.gz: 3dfd136cd8afdef71e728db387c87c8cb52a7d376b8902e8d6922281fcf0f5ca847fbbad05562abd8f3658b146c4f1a5b8b8b3aee5b2e7f80d106696ff116cc2
data/BUILD.md ADDED
@@ -0,0 +1,19 @@
1
+ # Build Instructions
2
+
3
+ To build the gem simply update the version number in `lib/capistrano/sozo_magento2/version.rb`.
4
+ Then you'll need to commit to vcs as the build process uses the git ls command to grab the files.
5
+ Following the commit, run the following:
6
+ ```
7
+ gem build capistrano-sozo_magento.gemspec
8
+ ```
9
+ The gem file generated will include the version number. To stop the file from being commited to the git repository move it into the pkg folder which is git ignored.
10
+
11
+ To test locally you can run the following to install the gem locally:
12
+ ```
13
+ gem install capistrano-sozo_magento2
14
+ ```
15
+
16
+ To push the gem to ruby-gems.org run the following:
17
+ ```
18
+ gem push capistrano-sozo_magento2-{version}.gem
19
+ ```
data/CHANGELOG.md ADDED
@@ -0,0 +1,80 @@
1
+ # SOZO Magento 2 Capistrano Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
+
8
+ Given a version number MAJOR.MINOR.PATCH, increment the:
9
+
10
+ * MAJOR version when you make incompatible API changes,
11
+ * MINOR version when you add functionality in a backwards-compatible manner, and
12
+ * PATCH version when you make backwards-compatible bug fixes.
13
+
14
+ ##### Types of changes
15
+ * [Added] for new features.
16
+ * [Changed] for changes in existing functionality.
17
+ * [Deprecated] for soon-to-be removed features.
18
+ * [Removed] for now removed features.
19
+ * [Fixed] for any bug fixes.
20
+ * [Security] in case of vulnerabilities.
21
+
22
+ ## [Unreleased]
23
+
24
+ ## [v1.3.0] - 2021-05-14
25
+ ### Added
26
+ - New task to check for ece-patches file `.magento.env.yaml` and to apply if it finds one.
27
+
28
+
29
+ ## [v1.2.1] - 2021-05-06
30
+ ### Fixed
31
+ - WordPress backup not respecting the :wp_backup false option
32
+ - Erroneous symlink created inside release directories
33
+ - Added simple text output in Slack message
34
+
35
+
36
+ ## [v1.2.0] - 2021-03-25
37
+ ### Added
38
+ - New variable `clear_failures` for future use.
39
+ - New Slack class to control the message template.
40
+
41
+ ### Changed
42
+ - Updated Slack messaging to newer version to future proof.
43
+ - Current directory fix now updates MAGE_ROOT as well.
44
+ - Standardised tasks order based on key capistrano core tasks.
45
+
46
+ ### Removed
47
+ - Removed dotenv from the gem.
48
+
49
+ ### Fixed
50
+ - Fix issue when there were less than CAP_KEEP_BACKUPS available.
51
+
52
+
53
+ ## [v1.1.0] - 2021-02-24
54
+ ### Added
55
+ - Added defaults for the :wp_backup, :keep_backups and :slack_channel instead of using ENV's
56
+ - Added BUILD.md for reminders on how to build and publish the gem.
57
+
58
+ ### Changed
59
+ - Magento and WordPress backup's now in their own commands and invoked from the main call.
60
+ - Staging role now doesn't install composer dev requirements.
61
+
62
+ ### Removed
63
+ - ENV references cleaned out and updated in the Companion Composer plugin.
64
+
65
+ ### Fixed
66
+ - Confirm command now using correct symbols to display against roles.
67
+
68
+
69
+ ## [v1.0.1] - 2021-02-20
70
+ ### Added
71
+ - CHANGELOG.md
72
+ - License text
73
+ - Gem version badge to README.md
74
+
75
+ ### Fixed
76
+ - Documentation references to the gem.
77
+
78
+
79
+ ### [v1.0.0] - 2021-02-20
80
+ - Initial release
data/LICENSE CHANGED
@@ -0,0 +1,22 @@
1
+ SOZO Design Ltd EULA (End-User License Agreement)
2
+
3
+ sozodesign.co.uk
4
+ THIS LICENSE AGREEMENT (HEREINAFTER AGREEMENT) IS AN AGREEMENT BETWEEN YOU (THE PERSON OR COMPANY WHO IS BEING LICENSED TO USE THE SOFTWARE OR DOCUMENTATION) AND SOZO DESIGN LTD (HEREINAFTER WE/US/OUR). THE AGREEMENT APPLIES TO ALL PRODUCTS/SOFTWARE/SCRIPTS/SERVICES YOU PURCHASE FROM US.
5
+
6
+ 1. By purchasing the Software you acknowledge that you have read this Agreement, and that you agree to the content of the Agreement and its terms, and agree to use the Software in compliance with this Agreement.
7
+ 2. The Agreement comes into legal force at the moment when you order our Software from our site or receive it through email or on data medium at our discretion.
8
+ 3. We are the copyright holder of the Software. The Software or a portion of it is a copyrightable matter and is liable to protection by the law. Any activity that infringes the terms of this Agreement violates copyright law and will be prosecuted according to the current law. We reserve the right to revoke the license of any user who is holding an invalid license.
9
+ 4. This Agreement gives you the right to use only one copy of the Software on one Magento installation solely for your own personal or business use, subject to all other terms of this Agreement. A separate License should be purchased for each new Software installation. Any distribution of the Software without our consent, including noncommercial distribution is regarded as violation of this Agreement and entails liability, according to the current law.
10
+ 5. You may not use any part of the code in whole or part in any other software or product or website.
11
+ 6. You may not give, sell, distribute, sub-license, rent, lease or lend any portion of the Software or Documentation to anyone. You may not place the Software on a server so that it is accessible via a public network such as the Internet for distribution purposes.
12
+ 7. You are bound to preserve the copyright information intact, this includes the text/link at bottom.
13
+ 8. We reserve the right to publish a selected list of users of our Software.
14
+ 9. We will not be liable to you for any damages (including any loss of profits/saving, or incidental or consequential) caused to you, your information and your business arising out of the use or inability to use this Software.
15
+ 10. We are not liable for prosecution arising from the use of the Software against law or for any illegal use.
16
+ 11. If you fail to use the Software in accordance with the terms and conditions of this License Agreement, it constitutes a breach of the agreement, and your license to use the program is revoked.
17
+ 12. SOZO Design Ltd reserves the right to change this license agreement at any time and impose its clauses at any given time.
18
+ 13. License agreement remains effective until terminated. We retain the right to terminate your license to use the Software at any time, if in its sole discretion, you are not abiding by the terms of the Agreement, including, but not limited to, obscuring or removing any link or copyright notice as specified in this agreement. You may terminate it at any time by destroying all copies of the Software. Termination of this Agreement does not bind us to return you the amount spent for purchase of the Software.
19
+ 14. If you continue to use the Software after SOZO Design Ltd gives you notice of termination of your license, you hereby agree to accept an injunction to enjoin you from its further use and to pay all costs (including but not limited to reasonable attorney fees) to enforce our revocation of your license and any damages suffered by us because of your misuse of the Software.
20
+ 15. This software designed for Magento Open Source and Magento Commerce edition SOZO Design Ltd does not guarantee correct work of this extension on any other Magento edition except Magento Open Source and Magento Commerce edition. SOZO Design Ltd does not provide extension support in case of incorrect edition usage.
21
+ 16. Support period will be defined in accordance with the plan selected during the purchase. Within the given period you will be eligible to receive software updates as well as technical support.
22
+
data/README.md CHANGED
@@ -1,11 +1,13 @@
1
- #Capistrano::SozoMagento2
1
+ # Capistrano::SozoMagento2
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/capistrano-sozo_magento2.svg)](https://badge.fury.io/rb/capistrano-sozo_magento2)
2
4
 
3
5
  ## Installation
4
6
  It is advised to use bundler.
5
7
 
6
8
  1. Add the following to your projects `Gemfile`
7
9
  ```
8
- gem 'capistrano-sozo-magento2'
10
+ gem "capistrano-sozo_magento2", "~> 1.3"
9
11
  ```
10
12
  2. Install
11
13
  ```
@@ -16,19 +18,59 @@ bundle install
16
18
  Make sure the following lines are added to your project's `Capfile`:
17
19
  ```
18
20
  # Load SOZO Magento tasks
19
- require 'capistrano/sozo-magento2'
21
+ require 'capistrano/sozo_magento2'
20
22
  ```
21
23
  We recommend putting them in the following location:
22
24
  ```
23
25
  # Load DSL and set up stages
24
26
  require 'capistrano/setup'
25
27
 
26
- # Load SOZO Magento tasks
27
- require 'capistrano/sozo-magento2'
28
-
29
28
  # Include default deployment tasks
30
29
  require 'capistrano/deploy'
31
30
 
31
+ # Load SOZO Magento tasks
32
+ require 'capistrano/sozo_magento2'
33
+
32
34
  require "capistrano/scm/git"
33
35
  install_plugin Capistrano::SCM::Git
34
- ```
36
+ ```
37
+
38
+ ### Built Ins
39
+ We have the following built ins setup for default projects.
40
+ ```
41
+ set :linked_files, []
42
+
43
+ set :linked_dirs, [
44
+ 'magento/pub/media',
45
+ 'magento/pub/sitemap',
46
+ 'magento/var/amasty/geoip',
47
+ 'magento/var/backups',
48
+ 'magento/var/composer_home',
49
+ 'magento/var/importexport',
50
+ 'magento/var/import_history',
51
+ 'magento/var/export',
52
+ 'magento/var/log',
53
+ 'magento/var/nginx',
54
+ 'magento/var/report',
55
+ 'magento/var/session',
56
+ 'magento/var/tmp',
57
+ 'magento/wp/wp-content/uploads'
58
+ ]
59
+ ```
60
+ If you would like to customize the linked files or directories for your project, you can copy either one or both of the above arrays into the `deployment/deploy.rb` or `deployment/deploy/*.rb` files and tweak them to fit your project's needs. Alternatively, you can add a single linked dir (or file) using `append` like this:
61
+ ```
62
+ append :linked_dirs, 'path/to/link'
63
+ ```
64
+
65
+ ## Versioning
66
+ 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
+
68
+
69
+ ## Authors
70
+ * **Clive Walkden** - *Initial work* - [SOZO Design Ltd](https://github.com/sozo-design)
71
+
72
+ See also the list of [contributors](https://github.com/sozo-design/capistrano-sozo-magento2/contributors) who participated in this project.
73
+
74
+
75
+ ## License
76
+ This project is licensed under the Proprietary License - see the [LICENSE](./LICENSE) file for details
@@ -10,14 +10,15 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["clive@sozodesign.co.uk"]
11
11
  spec.description = %q{Magento 2 support for Capistrano 3.x in SOZO hosted environments}
12
12
  spec.summary = %q{Magento 2 support for Capistrano 3.x in SOZO hosted environments}
13
- spec.homepage = "https://github.com/sozodesign/capistrano-sozo-magento2"
13
+ spec.homepage = "https://github.com/sozo-design/capistrano-sozo-magento2"
14
14
  spec.license = "Proprietary"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(build|test|spec|features)/}) }
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,6 +1,4 @@
1
1
  require 'date'
2
- require 'dotenv'
3
- Dotenv.load
4
2
 
5
3
  SSHKit.config.command_map[:composer] = 'php -dmemory_limit=-1 -f /usr/local/bin/composer'
6
4
  SSHKit.config.command_map[:n98magerun] = '/usr/local/bin/n98-magerun'
@@ -19,32 +17,34 @@ load File.expand_path('../tasks/server.rake', __FILE__)
19
17
  load File.expand_path('../tasks/wordpress.rake', __FILE__)
20
18
 
21
19
  after 'deploy:updating', 'composer:install'
22
- after 'composer:install', 'magento:setup:permissions'
20
+ after 'deploy:updating', 'magento:patches:apply'
21
+ after 'deploy:updating', 'magento:setup:permissions'
23
22
 
24
23
  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'
24
+ before 'deploy:updated', 'db:backup'
25
+ before 'deploy:updated', 'sozo:config:setup'
26
+ before 'deploy:updated', 'magento:maintenance:enable'
28
27
 
29
28
  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'
29
+ after 'deploy:updated', 'magento:setup:upgrade'
30
+ after 'deploy:updated', 'magento:setup:di:compile'
31
+ after 'deploy:updated', 'magento:setup:static-content:deploy'
32
+ after 'deploy:updated', 'provision:permissions'
34
33
 
35
34
  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'
35
+ after 'deploy:finishing', 'fishpig:setup:install_theme'
36
+ after 'deploy:finishing', 'wordpress:sozo_mu'
37
+ after 'deploy:finishing', 'wordpress:cleanup'
38
+ after 'deploy:finishing', 'sozo:optimise'
39
+ after 'deploy:finishing', 'server:service:restart'
40
+ after 'deploy:finishing', 'magento:maintenance:disable'
42
41
 
43
42
  after 'deploy:finished', "slack:deployed"
44
- after 'slack:deployed', "db:cleanup"
43
+ after 'deploy:finished', "db:cleanup"
45
44
 
46
45
  after 'deploy:failed', "slack:failed"
47
- after 'slack:failed', 'magento:maintenance:disable'
46
+ after 'deploy:failed', "sozo:fix_current"
47
+ after 'deploy:failed', 'magento:maintenance:disable'
48
48
 
49
49
  namespace :load do
50
50
  task :defaults do
@@ -27,13 +27,16 @@ 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_db, ->{ ENV['WPDB_DATABASE'] }
31
- set :wp_backup, ->{ ENV['WPDB_BACKUP'] }
32
- set :keep_backups, ->{ ENV['CAP_KEEP_BACKUPS'] }
30
+ set :wp_backup, fetch(:wp_backup, true)
31
+ set :keep_backups, fetch(:keep_backups, 10)
33
32
 
34
33
  # Slack defaults
35
- set :slack_channel, ENV['SLACK_CHANNEL']
34
+ set :slack_channel, fetch(:slack_channel, '#deployments')
36
35
  set :slack_webhook, 'https://hooks.slack.com/services/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'
37
36
 
38
37
  # Deployment defaults
39
- set :confirm_deploy, fetch(:magento_deploy_confirm, [])
38
+ set :magento_deploy_confirm_roles, fetch(:magento_deploy_confirm_roles, [])
39
+
40
+ # Other defaults (for future use)
41
+ # Clear or leave the failed deployment dirs
42
+ 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.0.0"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  end
@@ -1,13 +1,13 @@
1
1
  namespace :composer do
2
2
  desc "Install the Composer dependencies"
3
3
  task :install do
4
- on roles :testing, :staging do
4
+ on roles(:all, filter: :composer_dev) do
5
5
  within release_path + 'magento/' do
6
6
  execute :composer, "install", fetch(:composer_dev_flags)
7
7
  end
8
8
  end
9
9
 
10
- on roles(:production) do
10
+ on roles(:all, exclude: :composer_dev) do
11
11
  within release_path + 'magento/' do
12
12
  execute :composer, "install", fetch(:composer_flags)
13
13
  end
@@ -16,13 +16,13 @@ namespace :composer do
16
16
 
17
17
  desc "Update the Composer dependencies"
18
18
  task :update do
19
- on roles :testing, :staging do
19
+ on roles(:all, filter: :composer_dev) do
20
20
  within release_path + 'magento/' do
21
21
  execute :composer, "update", fetch(:composer_dev_flags)
22
22
  end
23
23
  end
24
24
 
25
- on roles(:production) do
25
+ on roles(:all, exclude: :composer_dev) do
26
26
  within release_path + 'magento/' do
27
27
  execute :composer, "update", fetch(:composer_flags)
28
28
  end
@@ -7,20 +7,35 @@ 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_db_backup'
12
+ invoke 'db:wp_db_backup'
13
+ end
14
+ end
10
15
 
11
- # Backup using n98-magerun but don't include the logs or sessions data
16
+ desc "Backup Magento database"
17
+ task :mag_db_backup do
18
+ on roles :all do
12
19
  info "Backing up Magento database."
13
20
  execute :n98magerun, 'db:dump', "--root-dir='#{fetch(:mage_root)}'",
14
21
  '--compression="gzip"',
15
22
  '--strip="@log @sessions"',
16
23
  '--force', "#{fetch(:backupdir)}/#{fetch(:date_path)}_m2.sql.gz"
24
+ end
25
+ end
17
26
 
18
- if ENV['WPDB_BACKUP'] == "true"
27
+ desc "Backup WordPress database"
28
+ task :wp_db_backup do
29
+ # Backup the database with a timestamp
30
+ on roles :all do
31
+ if (fetch(:wp_backup) == "true")
19
32
  info "Backing up WordPress database."
20
33
  execute :n98magerun, 'db:dump', "--root-dir='#{fetch(:mage_root)}'",
21
34
  '--compression="gzip"',
22
35
  '--connection="wordpress"',
23
36
  '--force', "#{fetch(:backupdir)}/#{fetch(:date_path)}_wp.sql.gz"
37
+ else
38
+ info "WordPress backup set to false"
24
39
  end
25
40
  end
26
41
  end
@@ -38,11 +53,11 @@ namespace :db do
38
53
  files = (valid - valid.last(fetch(:keep_backups).to_i)).map do |backup|
39
54
  "#{fetch(:backupdir)}" + "/" + (backup).to_s
40
55
  end
41
- end
42
56
 
43
- if files.any?
44
- files.each_slice(100) do |files_batch|
45
- 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
46
61
  end
47
62
  end
48
63
  end
@@ -1,6 +1,6 @@
1
1
  namespace :deploy do
2
2
  before :starting, :confirm_action do
3
- if fetch(:magento_deploy_confirm).include? fetch(:stage).to_s
3
+ if fetch(:magento_deploy_confirm_roles).include? fetch(:stage).to_s
4
4
  print "\e[0;31m Are you sure you want to deploy to #{fetch(:stage).to_s}? [y/n] \e[0m"
5
5
  proceed = STDIN.gets[0..0] rescue nil
6
6
  exit unless proceed == 'y' || proceed == 'Y'
@@ -244,4 +244,34 @@ namespace :magento do
244
244
  end
245
245
  end
246
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, '-dmemory_limit=-1', '-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, '-dmemory_limit=-1', '-f', 'magento/vendor/bin/ece-patches', 'revert --no-interaction'
269
+ else
270
+ info 'No patch file found, skipping.'
271
+ end
272
+ end
273
+ end
274
+ end
275
+ end
276
+
247
277
  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
 
@@ -78,6 +87,8 @@ namespace :sozo do
78
87
  execute :cp, "#{release_path}/environments/#{fetch(:environment)}/.htpasswd", "#{release_path}/magento/.htpasswd"
79
88
  end
80
89
  end
90
+
91
+ invoke! "sozo:fix_current"
81
92
  end
82
93
 
83
94
  desc "Git Check"
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.0.0
4
+ version: 1.3.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-02-20 00:00:00.000000000 Z
11
+ date: 2021-05-14 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
@@ -46,12 +32,15 @@ extensions: []
46
32
  extra_rdoc_files: []
47
33
  files:
48
34
  - ".gitignore"
35
+ - BUILD.md
36
+ - CHANGELOG.md
49
37
  - Gemfile
50
38
  - LICENSE
51
39
  - README.md
52
40
  - capistrano-sozo_magento.gemspec
53
41
  - lib/capistrano/sozo_magento2.rb
54
42
  - lib/capistrano/sozo_magento2/defaults.rb
43
+ - lib/capistrano/sozo_magento2/slack.rb
55
44
  - lib/capistrano/sozo_magento2/version.rb
56
45
  - lib/capistrano/tasks/composer.rake
57
46
  - lib/capistrano/tasks/db.rake
@@ -64,7 +53,7 @@ files:
64
53
  - lib/capistrano/tasks/sozo.rake
65
54
  - lib/capistrano/tasks/sozo_magento2.rake
66
55
  - lib/capistrano/tasks/wordpress.rake
67
- homepage: https://github.com/sozodesign/capistrano-sozo-magento2
56
+ homepage: https://github.com/sozo-design/capistrano-sozo-magento2
68
57
  licenses:
69
58
  - Proprietary
70
59
  metadata: {}
@@ -76,7 +65,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
65
  requirements:
77
66
  - - ">="
78
67
  - !ruby/object:Gem::Version
79
- version: '0'
68
+ version: 2.5.3
80
69
  required_rubygems_version: !ruby/object:Gem::Requirement
81
70
  requirements:
82
71
  - - ">="