capistrano-wearerequired 0.4.0.pre.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: adb958823033cdad89185e1e4f792d1394cc20ac
4
+ data.tar.gz: 98d296cd260b8fcaa481c601e10121585bd8a4b4
5
+ SHA512:
6
+ metadata.gz: f8204a6e9ca09e113d190facd6c4284b110216b6c774ef1de1adffb590a977e53c45b857103b1ad1d85abaad1d9d909784cf658b8537596a3c89df3f88cbfdb7
7
+ data.tar.gz: 29c09d97ac04c65d59f27a41fd41355eb14491200044f5dd7d7914c25da5c6992f1ac174672216ba0fa6a4198584dbfafc7d34880f6dc2e5093b3ab26b051d65
data/.editorconfig ADDED
@@ -0,0 +1,11 @@
1
+ # This file is for unifying the coding style for different editors and IDEs
2
+ # editorconfig.org
3
+
4
+ root = true
5
+
6
+ [*]
7
+ charset = utf-8
8
+ end_of_line = lf
9
+ insert_final_newline = true
10
+ trim_trailing_whitespace = true
11
+ indent_style = space
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in capistrano-required_tools.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # Capistrano::RequiredTools
2
+
3
+ A collection of tools for Capistrano.
4
+
5
+
6
+ ## Installation
7
+
8
+ 1. Add this line to your application's Gemfile to install the latest stable version:
9
+
10
+ ```ruby
11
+ gem 'capistrano-required_tools', :git => 'git@github.com:wearerequired/capistrano-required_tools.git', :branch => 'stable'
12
+ ```
13
+
14
+ Use `:tag => 'v0.3.0'` for a specific version.
15
+
16
+ 2. Execute:
17
+
18
+ ```
19
+ $ bundle
20
+ ```
21
+
22
+ 3. Require the library in your application's Capfile:
23
+
24
+ ```ruby
25
+ require 'capistrano/required_tools'
26
+ ```
27
+
28
+
29
+ ## Usage
30
+
31
+ ### Colors for Slackistrano
32
+
33
+ The class `SlackistranoMessagingColors` adds colors to the deploy messages posted to Slack.
34
+
35
+ Example:
36
+ ```ruby
37
+ set :slackistrano, {
38
+ klass: Capistrano::RequiredTools::SlackistranoMessagingColors,
39
+ channel: '#your-channel',
40
+ webhook: 'your-incoming-webhook-url'
41
+ }
42
+ ```
43
+
44
+ ### Extended Messaging for Slackistrano
45
+
46
+ The class `SlackistranoMessagingExtended` adds colors, a link to the current diff, the current revision and branch, the name of the deployer and suppresses updating messages.
47
+
48
+ Example:
49
+ ```ruby
50
+ set :slackistrano, {
51
+ klass: Capistrano::RequiredTools::SlackistranoMessagingExtended,
52
+ channel: '#your-channel',
53
+ webhook: 'your-incoming-webhook-url',
54
+ icon_emoji: ':ship:',
55
+ username: 'deploybot'
56
+ }
57
+ ```
58
+
59
+ See [Customizing the Messaging](https://github.com/phallstrom/slackistrano/tree/v3.1.0#customizing-the-messaging) for more information.
60
+
61
+ ### Additonal tasks
62
+
63
+ To **delete all content from Composer's cache directories** run:
64
+
65
+ ```
66
+ cap staging composer:clear_cache
67
+ ```
68
+
69
+ To **clean up all old releases** but the last run:
70
+
71
+ ```
72
+ cap staging deploy:cleanup_all
73
+ ```
74
+
75
+ To **install WordPress translations** set `:wp_language` and run:
76
+
77
+ ```
78
+ set :wp_languages, [
79
+ 'de_DE',
80
+ 'it_IT
81
+ ]
82
+
83
+ cap staging wordpress:install_translations
84
+ ```
85
+
86
+ To **update WordPress translations** run:
87
+
88
+ ```
89
+ cap staging wordpress: update_translations
90
+ ```
91
+
92
+ To **clear OPcache** of your site set `:wp_clear_opcache, true` and run:
93
+
94
+ ```
95
+ cap staging wordpress:clear_opcache
96
+ ```
97
+
98
+ (Requires the [WP-CLI Clear OPcache](https://packagist.org/packages/wearerequired/wp-cli-clear-opcache) plugin.)
99
+
100
+ ## Changelog
101
+
102
+ ### 0.4.0
103
+
104
+ * Added `wordpress:clear_opcache` task.
105
+ * Added new messaging class for Slackistrano for more informative notifications.
106
+ * Updated both messaging classes to support a custom icon (via `icon_url` or `icon_emoji`) and bot name (via `username`).
107
+
108
+ ### 0.3.0
109
+
110
+ * Added `deploy:cleanup_all` task.
111
+ * Added `wordpress:install_translations` and `wordpress:update_translations` tasks.
112
+
113
+ ### 0.2.0
114
+
115
+ * Added `composer:clear_cache` task.
116
+
117
+ ### 0.1.0
118
+
119
+ * Initial version.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'capistrano/wearerequired/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-wearerequired"
8
+ spec.version = Capistrano::Wearerequired::VERSION
9
+ spec.description = "Capistrano::Wearerequired is a collection of recipes and tasks specialized on WordPress deployment."
10
+ spec.summary = "Recipes for Capistrano used by required gmbh"
11
+ spec.authors = ["wearerequired", "Pascal Birchler", "Ulrich Pogson", "Dominik Schilling"]
12
+ spec.email = "info@required.ch"
13
+ spec.homepage = "https://github.com/wearerequired/capistrano-wearerequired"
14
+ spec.license = "GPL-2.0+"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.required_ruby_version = ">= 2.0"
20
+ spec.add_dependency "capistrano", "~> 3.6"
21
+ spec.add_dependency "slackistrano", "~> 3.1"
22
+ spec.add_dependency "capistrano-composer", "~> 0.0.6"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.13"
25
+ spec.add_development_dependency "rake", "~> 11.0"
26
+ end
@@ -0,0 +1 @@
1
+ load File.expand_path('../tasks/capistrano.rake', __FILE__)
@@ -0,0 +1 @@
1
+ load File.expand_path('../tasks/composer.rake', __FILE__)
@@ -0,0 +1,63 @@
1
+ require 'slackistrano/capistrano'
2
+
3
+ module Capistrano
4
+ module Wearerequired
5
+ class SlackistranoMessagingColors < Slackistrano::Messaging::Base
6
+
7
+ def initialize(env: nil, team: nil, channel: nil, token: nil, webhook: nil, icon_url: nil, icon_emoji: nil, username: nil)
8
+ super(env: env, team: team, channel: channel, token: token, webhook: webhook)
9
+ @icon_url = icon_url
10
+ @icon_emoji = icon_emoji
11
+ @username = username
12
+ end
13
+
14
+ def payload_for_updating
15
+ make_message(super.merge(color: '#E7E7E7'))
16
+ end
17
+
18
+ def payload_for_reverting
19
+ make_message(super.merge(color: '#E7E7E7'))
20
+ end
21
+
22
+ def payload_for_updated
23
+ make_message(super.merge(color: 'good'))
24
+ end
25
+
26
+ def payload_for_reverted
27
+ make_message(super.merge(color: 'good'))
28
+ end
29
+
30
+ def payload_for_failed
31
+ make_message(super.merge(color: 'danger'))
32
+ end
33
+
34
+ def icon_url
35
+ if @icon_url.nil?
36
+ super
37
+ else
38
+ @icon_url
39
+ end
40
+ end
41
+
42
+ def icon_emoji
43
+ @icon_emoji
44
+ end
45
+
46
+ def username
47
+ if @username.nil?
48
+ super
49
+ else
50
+ @username
51
+ end
52
+ end
53
+
54
+ private ##################################################
55
+
56
+ def make_message(options={})
57
+ attachment = options.reject{|k, v| v.nil? }
58
+ {attachments: [attachment]}
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,164 @@
1
+ require 'slackistrano/capistrano'
2
+
3
+ module Capistrano
4
+ module Wearerequired
5
+ class SlackistranoMessagingExtended < Slackistrano::Messaging::Base
6
+
7
+ def initialize(env: nil, team: nil, channel: nil, token: nil, webhook: nil, icon_url: nil, icon_emoji: nil, username: nil)
8
+ super(env: env, team: team, channel: channel, token: token, webhook: webhook)
9
+ @icon_url = icon_url
10
+ @icon_emoji = icon_emoji
11
+ @username = username
12
+ end
13
+
14
+ # Suppress updating message.
15
+ def payload_for_updating
16
+ nil
17
+ end
18
+
19
+ # Suppress reverting message.
20
+ def payload_for_reverting
21
+ nil
22
+ end
23
+
24
+ def payload_for_reverted
25
+ make_message(super.merge(color: 'good'))
26
+ end
27
+
28
+ def payload_for_failed
29
+ make_message(super.merge(color: 'danger'))
30
+ end
31
+
32
+ def icon_url
33
+ if @icon_url.nil?
34
+ super
35
+ else
36
+ @icon_url
37
+ end
38
+ end
39
+
40
+ def icon_emoji
41
+ @icon_emoji
42
+ end
43
+
44
+ def username
45
+ if @username.nil?
46
+ super
47
+ else
48
+ @username
49
+ end
50
+ end
51
+
52
+ # Get current revision
53
+ def current_revision
54
+ fetch(:current_revision)
55
+ end
56
+
57
+ # Get previous revision
58
+ def previous_revision
59
+ fetch(:previous_revision)
60
+ end
61
+
62
+ # Get individual parts of the repo_url
63
+ def repo
64
+ repo_url.match(/(git@|https:\/\/)(?<host>([\w\.@]+))(\/|:)(?<owner>[\w,\-,\_]+)\/(?<repo>[\w,\-,\_]+)(.git){0,1}((\/){0,1})/)
65
+ end
66
+
67
+ # Get information about the revision being deployed
68
+ def revision
69
+ if repo.nil? || current_revision.nil?
70
+ 'Unknown'
71
+ else
72
+ current_revision_url
73
+ end
74
+ end
75
+
76
+ # Get current revision URL
77
+ def current_revision_url
78
+ "<https://%{host}/%{owner}/%{repo}/%{commit}/%{revision}|%{revision_short}@%{branch}>" % {
79
+ :host => repo[:host],
80
+ :owner => repo[:owner],
81
+ :repo => repo[:repo],
82
+ :commit => 'bitbucket.org' == repo[:host] ? 'commits' : 'commit',
83
+ :revision => current_revision,
84
+ :revision_short => current_revision[0..10],
85
+ :branch => branch
86
+ }
87
+ end
88
+
89
+ # Get revision comparison
90
+ def revision_compare_url
91
+ "<https://%{host}/%{owner}/%{repo}/%{compare}/%{previous_revision}...%{current_revision}|%{revision_short}>" % {
92
+ :host => repo[:host],
93
+ :owner => repo[:owner],
94
+ :repo => repo[:repo],
95
+ :compare => 'bitbucket.org' == repo[:host] ? 'branches/compare' : 'compare',
96
+ :current_revision => current_revision,
97
+ :previous_revision => previous_revision,
98
+ :revision_short => previous_revision[0..7] + '...' + current_revision[0..7]
99
+ }
100
+ end
101
+
102
+ def author_icon
103
+ "https://required.com/content/themes/required-valencia/img/character-%{name}-300x300.png" % { name: deployer.downcase }
104
+ end
105
+
106
+ def author_link
107
+ "https://required.com/team/%{name}/" % { name: deployer.downcase }
108
+ end
109
+
110
+ def footer_icon
111
+ if repo.nil?
112
+ ''
113
+ elsif 'bitbucket.org' == repo[:host]
114
+ 'https://bitbucket.org/site/master/avatar/64/'
115
+ elsif 'gitlab.com' == repo[:host]
116
+ 'https://gitlab.com/uploads/system/project/avatar/13083/logo-extra-whitespace.png'
117
+ elsif 'github.com' == repo[:host]
118
+ 'https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png'
119
+ end
120
+ end
121
+
122
+ def footer
123
+ if repo.nil? || current_revision.nil? || previous_revision.nil?
124
+ ''
125
+ else
126
+ 'Diff: ' + revision_compare_url
127
+ end
128
+ end
129
+
130
+ # More detailed updated message.
131
+ def payload_for_updated
132
+ {
133
+ attachments: [{
134
+ color: 'good',
135
+ pretext: application + ' was successfully deployed :white_check_mark:',
136
+ author_name: deployer.capitalize,
137
+ author_icon: author_icon,
138
+ author_link: author_link,
139
+ footer: footer,
140
+ footer_icon: footer_icon,
141
+ fields: [{
142
+ title: 'Environment',
143
+ value: stage.capitalize,
144
+ short: true
145
+ }, {
146
+ title: 'Revision',
147
+ value: revision,
148
+ short: true
149
+ }],
150
+ fallback: super[:text]
151
+ }]
152
+ }
153
+ end
154
+
155
+ private ##################################################
156
+
157
+ def make_message(options={})
158
+ attachment = options.reject{|k, v| v.nil? }
159
+ {attachments: [attachment]}
160
+ end
161
+
162
+ end
163
+ end
164
+ end
@@ -0,0 +1,10 @@
1
+ namespace :deploy do
2
+
3
+ desc <<-DESC
4
+ Clean up all old releases but the last.
5
+ DESC
6
+ task :cleanup_all do
7
+ set :keep_releases, 1
8
+ invoke "deploy:cleanup"
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ namespace :composer do
2
+
3
+ desc <<-DESC
4
+ Deletes all content from Composer's cache directories.
5
+ DESC
6
+ task :clear_cache do
7
+ invoke "composer:run", "clear-cache"
8
+ end
9
+ end
@@ -0,0 +1,55 @@
1
+ namespace :wordpress do
2
+
3
+ desc <<-DESC
4
+ Install WordPress translations.
5
+ DESC
6
+ task :install_translations do
7
+ next unless fetch(:wp_languages).any?
8
+
9
+ on roles(:app) do
10
+ within release_path do
11
+ fetch(:wp_languages).each do |language|
12
+ execute :wp, "core language install #{language}"
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ desc <<-DESC
19
+ Update WordPress translations.
20
+ DESC
21
+ task :update_translations do
22
+ next unless fetch(:wp_languages).any?
23
+
24
+ on roles(:app) do
25
+ within release_path do
26
+ execute :wp, "core language update"
27
+ end
28
+ end
29
+ end
30
+
31
+ desc <<-DESC
32
+ Clear OPcache.
33
+ DESC
34
+ task :clear_opcache do
35
+ next unless fetch(:wp_clear_opcache)
36
+
37
+ on roles(:app) do
38
+ within release_path do
39
+ execute :wp, "plugin activate wp-cli-clear-opcache --quiet"
40
+ execute :wp, "opcache clear"
41
+ end
42
+ end
43
+ end
44
+
45
+ after 'deploy:finishing', 'wordpress:install_translations'
46
+ after 'deploy:finishing', 'wordpress:update_translations'
47
+ after 'deploy:finishing', 'wordpress:clear_opcache'
48
+ end
49
+
50
+ namespace :load do
51
+ task :defaults do
52
+ set :wp_languages, []
53
+ set :wp_clear_opcache, false
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Wearerequired
3
+ VERSION = "0.4.0-alpha.1"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ load File.expand_path('../tasks/wordpress.rake', __FILE__)
@@ -0,0 +1,12 @@
1
+ require "capistrano/wearerequired/version"
2
+
3
+ module Capistrano
4
+ module Wearerequired
5
+ end
6
+ end
7
+
8
+ require "capistrano/wearerequired/slackistrano_messaging_colors"
9
+ require "capistrano/wearerequired/slackistrano_messaging_extended"
10
+ require "capistrano/wearerequired/composer.rb"
11
+ require "capistrano/wearerequired/capistrano.rb"
12
+ require "capistrano/wearerequired/wordpress.rb"
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-wearerequired
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0.pre.alpha.1
5
+ platform: ruby
6
+ authors:
7
+ - wearerequired
8
+ - Pascal Birchler
9
+ - Ulrich Pogson
10
+ - Dominik Schilling
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2017-09-15 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: capistrano
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '3.6'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '3.6'
30
+ - !ruby/object:Gem::Dependency
31
+ name: slackistrano
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: '3.1'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '3.1'
44
+ - !ruby/object:Gem::Dependency
45
+ name: capistrano-composer
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: 0.0.6
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: 0.0.6
58
+ - !ruby/object:Gem::Dependency
59
+ name: bundler
60
+ requirement: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - "~>"
63
+ - !ruby/object:Gem::Version
64
+ version: '1.13'
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '1.13'
72
+ - !ruby/object:Gem::Dependency
73
+ name: rake
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - "~>"
77
+ - !ruby/object:Gem::Version
78
+ version: '11.0'
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '11.0'
86
+ description: Capistrano::Wearerequired is a collection of recipes and tasks specialized
87
+ on WordPress deployment.
88
+ email: info@required.ch
89
+ executables: []
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - ".editorconfig"
94
+ - ".gitignore"
95
+ - Gemfile
96
+ - README.md
97
+ - Rakefile
98
+ - capistrano-wearerequired.gemspec
99
+ - lib/capistrano/wearerequired.rb
100
+ - lib/capistrano/wearerequired/capistrano.rb
101
+ - lib/capistrano/wearerequired/composer.rb
102
+ - lib/capistrano/wearerequired/slackistrano_messaging_colors.rb
103
+ - lib/capistrano/wearerequired/slackistrano_messaging_extended.rb
104
+ - lib/capistrano/wearerequired/tasks/capistrano.rake
105
+ - lib/capistrano/wearerequired/tasks/composer.rake
106
+ - lib/capistrano/wearerequired/tasks/wordpress.rake
107
+ - lib/capistrano/wearerequired/version.rb
108
+ - lib/capistrano/wearerequired/wordpress.rb
109
+ homepage: https://github.com/wearerequired/capistrano-wearerequired
110
+ licenses:
111
+ - GPL-2.0+
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '2.0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">"
125
+ - !ruby/object:Gem::Version
126
+ version: 1.3.1
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.6.11
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Recipes for Capistrano used by required gmbh
133
+ test_files: []