capistrano-slacky 0.1.2 → 0.2.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: 7d8a000422ee77540816f23c92063aaafbc39d62c1d7328bca687abe74c42976
4
- data.tar.gz: 96fea627fc2ef504cb8597a3c4c904ac75fda310b142f4e0e700e96659b9a6ea
3
+ metadata.gz: 00b2aed8c3c0bcd18970ed47c305cca3143c5c535bcb5ca10a693e29b4c1bc5b
4
+ data.tar.gz: 7c90f64ceefb7e2ea35379e018d9ce95a0d9f271e20959671ad7b512fd50818d
5
5
  SHA512:
6
- metadata.gz: a2290b5b024df873244e1a0196befec28381519aa5ad8ccdecf5c2d67931e0653cc68fc8c4325809381a038d8fe890ccff88dcfdb6969994337ffc61ad52d7d4
7
- data.tar.gz: bbca074fb05c97288aecbdf858cfcdb03dabbcd2cc969c183e42d39f17e9f32171cb29f5fe762e6df3301dbaf3fb71d88e703312d37adedc2f4a7b64a9984689
6
+ metadata.gz: 91e5c94bb9316628a420db5b6c3b94afbb71df72beb437921475835bfb903f92d261b9dfd59a8f038043633ccfd73d7f73ace86983254ed78048d306c948f2de
7
+ data.tar.gz: f31562940b77ca44bde8912af5368fc32e0012049d6a8f196fe761799149658d49ce44d1384e062ceb3a07d8da886bf3512e3e8aa1dce167a50f050d4c0a1d61
data/CHANGELOG.md CHANGED
@@ -4,6 +4,28 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [Unreleased]
8
+
9
+ ## [0.2.0] - 2021-12-20
10
+ ### Added
11
+ - Add new header emoticons. ([@chubchenko][])
12
+
13
+ ## [0.1.5] - 2021-11-11
14
+ ### Fixed
15
+ - Add fall back in case of the primary server is not defined. ([@chubchenko][])
16
+ - Require `json` to convert `Hash` object to `JSON`. ([@chubchenko][])
17
+
18
+ ## [0.1.4] - 2021-07-27
19
+ ### Fixed
20
+ - Ensure that `:current_revision` exists during rollback. ([@chubchenko][])
21
+
22
+ ## [0.1.3] - 2021-06-14
23
+ ### Changed
24
+ - Update `README.md`. ([@chubchenko][])
25
+
26
+ ### Fixed
27
+ - Change commit message encoding to `UTF-8`. ([@chubchenko][])
28
+
7
29
  ## [0.1.2] - 2021-06-03
8
30
  ### Changed
9
31
  - Use `I18n.t` instead of `t`. ([@chubchenko][])
@@ -31,7 +53,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
31
53
  - Initial version. ([@chubchenko][])
32
54
 
33
55
  [@chubchenko]: https://github.com/chubchenko
34
- [Unreleased]: https://github.com/chubchenko/capistrano-slacky/compare/v0.1.1...HEAD
56
+ [Unreleased]: https://github.com/chubchenko/capistrano-slacky/compare/v0.2.0...HEAD
57
+ [0.2.0]: https://github.com/chubchenko/capistrano-slacky/compare/v0.1.5...v0.2.0
58
+ [0.1.5]: https://github.com/chubchenko/capistrano-slacky/compare/v0.1.4...v0.1.5
59
+ [0.1.4]: https://github.com/chubchenko/capistrano-slacky/compare/v0.1.3...v0.1.4
60
+ [0.1.3]: https://github.com/chubchenko/capistrano-slacky/compare/v0.1.2...v0.1.3
35
61
  [0.1.2]: https://github.com/chubchenko/capistrano-slacky/compare/v0.1.1...v0.1.2
36
62
  [0.1.1]: https://github.com/chubchenko/capistrano-slacky/compare/v0.1.0...v0.1.1
37
63
  [0.1.0]: https://github.com/chubchenko/capistrano-slacky/releases/tag/v0.1.0
data/README.md CHANGED
@@ -1,14 +1,123 @@
1
+ <div align="center">
2
+ <img align="center"
3
+ height="100"
4
+ title="capistrano-slacky logo"
5
+ src="./assets/images/logo.svg">
6
+ </div>
7
+
8
+ [![gem version][9]][10]
1
9
  [![build][1]][2]
10
+ [![downloads][11]][12]
2
11
 
3
12
  # capistrano-slacky
4
13
 
5
- Send `Capistrano` deployment status to `Slack`.
14
+ Send `Capistrano` deployment status to `Slack` via the Incoming Webhooks integration.
15
+
16
+ - Messages are built on the basis of the [Block Kit][13]. See [Demo](#demo) section.
17
+ - Fires after every successful/failed deployment or rollback.
18
+ - Use _Incoming Webhook URL_ from the remote server.
19
+ - Send commit log between 2 deployments.
20
+
21
+ ## Table of Contents
22
+
23
+ - [Requirements](#requirements)
24
+ - [Installation](#installation)
25
+ - [Configuration](#configuration)
26
+ - [Usage](#usage)
27
+ - [Demo](#demo)
28
+
29
+ ## Requirements
30
+
31
+ - Ruby >= 2.5
32
+ - Capistrano ~> 3.0
33
+ - Slack
34
+
35
+ ## Installation
36
+
37
+ Add the following line to your `Gemfile`:
38
+
39
+ ```ruby
40
+ gem "capistrano-slacky", "~> 0.1", require: false
41
+ ```
42
+
43
+ And then execute:
44
+
45
+ ```bash
46
+ bundle install
47
+ ```
48
+
49
+ ## Configuration
50
+
51
+ Out of the box, the gem has a default configuration:
52
+
53
+ ```ruby
54
+ set :slacky, username: "ChatOps", # Set your bot's user name.
55
+ icon_emoji: ":robot_face:", # Emoji to use as the icon for this message.
56
+ channel: "#deployment", # The name of the channel to send a message to.
57
+ klass: Capistrano::Slacky::Messaging::Default # The class that responsible for creating a message.
58
+ ```
59
+
60
+ So you can easily tweak your deployment messages and all other configuration to what you want.
61
+
62
+ ## Usage
63
+
64
+ Require the library in your application's Capfile
65
+
66
+ ```ruby
67
+ require "capistrano/slacky"
68
+ ```
69
+
70
+ - Add an [Incoming Webhooks][4] to your Slack.
71
+ - The received _Incoming Webhook URL_ must be uploaded to the remote server. It should be stored in a `shared` directory under the following path `config/slacky.yml`.
72
+ - Run `cap production slacky:ping` command to test your integration.
73
+
74
+ That's all, deploy your application as usual and you will see a deployment notification in your Slack channel.
75
+
76
+ In case if you want to disable deployment notifications for a specific stage just set `slacky` to `false`.
77
+
78
+ ```ruby
79
+ set :slacky, false
80
+ ```
81
+
82
+ ## Demo
83
+
84
+ ![Deployed successfully][5]
85
+
86
+ ![Reverted successfully][6]
87
+
88
+ ## Supported Ruby Versions
89
+
90
+ This library aims to support and is [tested against][2] the following Ruby implementations:
91
+
92
+ - Ruby 2.5
93
+ - Ruby 2.6
94
+ - Ruby 2.7
95
+ - Ruby 3.0
96
+
97
+ If something doesn't work on one of these Ruby versions, it's a bug.
98
+
99
+ ## Versioning
100
+
101
+ This library aims to adhere to [Semantic Versioning 2.0.0][4]. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, that version should be immediately yanked, and/or a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions. As a result of this policy, you can (and should) specify a dependency on this gem using the [Pessimistic Version Constraint][5] with two digits of precision. For example:
102
+
103
+ ```ruby
104
+ gem "capistrano-slacky", "~> 0.1"
105
+ ```
6
106
 
7
107
  ## License
8
108
 
9
109
  [MIT][3]
10
110
 
11
-
12
111
  [1]: https://github.com/chubchenko/capistrano-slacky/actions/workflows/build.yml/badge.svg
13
112
  [2]: https://github.com/chubchenko/capistrano-slacky/actions/workflows/build.yml
14
113
  [3]: https://choosealicense.com/licenses/mit
114
+ [4]: https://api.slack.com/messaging/webhooks
115
+ [5]: ./assets/images/deployed_successfully.jpg
116
+ [6]: ./assets/images/deployment_failed.jpg
117
+ [7]: ./assets/images/reverted_successfully.jpg
118
+ [8]: ./assets/images/rollback_failed.jpg
119
+ [9]: https://badge.fury.io/rb/capistrano-slacky.svg
120
+ [10]: https://badge.fury.io/rb/capistrano-slacky
121
+ [11]: https://img.shields.io/gem/dt/capistrano-slacky
122
+ [12]: https://rubygems.org/gems/capistrano-slacky
123
+ [13]: https://api.slack.com/block-kit
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Capistrano
4
+ module Slacky
5
+ module Command
6
+ class CurrentRevision
7
+ REVISION_FILE = "REVISION"
8
+
9
+ private_constant :REVISION_FILE
10
+
11
+ def self.call
12
+ output = nil
13
+
14
+ ::Capistrano::Slacky.on(within: :release) do
15
+ output = ::SSHKit::Backend.current.capture(:cat, REVISION_FILE)
16
+ end
17
+
18
+ output
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -54,6 +54,9 @@ module Capistrano
54
54
  "0" => ":zero:"
55
55
  }.freeze
56
56
 
57
+ DEFAULT_ENCODING = "UTF-8"
58
+ private_constant :DEFAULT_ENCODING
59
+
57
60
  def initialize(index:, sha:, commit:)
58
61
  @index = index
59
62
  @sha = sha
@@ -71,7 +74,7 @@ module Capistrano
71
74
  end
72
75
 
73
76
  def commit
74
- @commit.delete('"').strip
77
+ @commit.delete('"').strip.force_encoding(DEFAULT_ENCODING)
75
78
  end
76
79
 
77
80
  def to_a
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "command/current_revision"
3
4
  require_relative "command/duration"
4
5
  require_relative "command/diff"
@@ -9,14 +9,18 @@ module Capistrano
9
9
  ":drooling_face:",
10
10
  ":sunglasses:",
11
11
  ":partying_face:",
12
- ":heart_eyes:"
12
+ ":heart_eyes:",
13
+ ":star-struck:",
14
+ ":yum:"
13
15
  ].freeze
14
16
 
15
17
  REVERTED_SUCCESSFULLY = [
16
18
  ":upside_down_face:",
17
19
  ":pensive:",
18
20
  ":face_with_raised_eyebrow:",
19
- ":worried:"
21
+ ":worried:",
22
+ ":pleading_face:",
23
+ ":shushing_face:"
20
24
  ].freeze
21
25
 
22
26
  DEPLOYMENT_FAILED = [
@@ -26,7 +30,10 @@ module Capistrano
26
30
  ":woozy_face:",
27
31
  ":exploding_head:",
28
32
  ":sob:",
29
- ":cry:"
33
+ ":cry:",
34
+ ":dizzy_face:",
35
+ ":face_with_hand_over_mouth:",
36
+ ":broken_heart:"
30
37
  ].freeze
31
38
 
32
39
  ROLLBACK_FAILED = DEPLOYMENT_FAILED
@@ -9,7 +9,8 @@ module Capistrano
9
9
 
10
10
  PATH_MAP = {
11
11
  repository: -> { Path.repo_path },
12
- shared: -> { Path.shared_path }
12
+ shared: -> { Path.shared_path },
13
+ release: -> { Path.release_path }
13
14
  }.freeze
14
15
 
15
16
  private_constant :PATH_MAP
@@ -17,7 +18,9 @@ module Capistrano
17
18
  module_function
18
19
 
19
20
  def on(within:, &block)
20
- ::Capistrano::DSL.on(::Capistrano::Configuration.env.primary(:app)) do
21
+ role = ::Capistrano::Configuration.env.primary(:app) || ::Capistrano::Configuration.env.roles(:all).first
22
+
23
+ ::Capistrano::DSL.on(role) do
21
24
  ::SSHKit::Backend.current.within(PATH_MAP.fetch(within).call, &block)
22
25
  end
23
26
  end
@@ -5,6 +5,8 @@ require_relative "messaging"
5
5
  module Capistrano
6
6
  module Slacky
7
7
  class Payload
8
+ require "json"
9
+
8
10
  def initialize(env:, action:)
9
11
  @env = env
10
12
  @action = action
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Capistrano
4
4
  module Slacky
5
- VERSION = "0.1.2"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  namespace :load do
4
+ desc "Load default configuration for slacky"
4
5
  task :defaults do
5
6
  append :linked_files, "config/slacky.yml"
6
7
  end
@@ -7,7 +7,7 @@ namespace :slacky do
7
7
  end
8
8
 
9
9
  desc "Slacky after successful rollback"
10
- task :reverted do
10
+ task reverted: [:ensure_current_revision] do
11
11
  Capistrano::Slacky::Runner.call(action: :reverted)
12
12
  end
13
13
 
@@ -25,4 +25,9 @@ namespace :slacky do
25
25
  Capistrano::Slacky::Runner.call(action: action)
26
26
  end
27
27
  end
28
+
29
+ desc "Ensure that the current revision is set"
30
+ task :ensure_current_revision do
31
+ set_if_empty(:current_revision) { Capistrano::Slacky::Command::CurrentRevision.call }
32
+ end
28
33
  end
metadata CHANGED
@@ -1,35 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-slacky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Chubchenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-03 00:00:00.000000000 Z
11
+ date: 2021-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 3.0.0
20
17
  - - "~>"
21
18
  - !ruby/object:Gem::Version
22
19
  version: '3.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 3.0.0
30
27
  - - "~>"
31
28
  - !ruby/object:Gem::Version
32
29
  version: '3.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rake
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -72,7 +72,7 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0.21'
75
- description: Send Capistrano deployment status to Slack via the incoming webhooks
75
+ description: Send Capistrano deployment status to Slack via the Incoming Webhooks
76
76
  integration
77
77
  email: artem.chubchenko@gmail.com
78
78
  executables: []
@@ -90,6 +90,7 @@ files:
90
90
  - lib/capistrano/slacky/block/root.rb
91
91
  - lib/capistrano/slacky/block/section.rb
92
92
  - lib/capistrano/slacky/command.rb
93
+ - lib/capistrano/slacky/command/current_revision.rb
93
94
  - lib/capistrano/slacky/command/diff.rb
94
95
  - lib/capistrano/slacky/command/duration.rb
95
96
  - lib/capistrano/slacky/configuration.rb
@@ -138,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  - !ruby/object:Gem::Version
139
140
  version: '0'
140
141
  requirements: []
141
- rubygems_version: 3.0.8
142
+ rubygems_version: 3.2.28
142
143
  signing_key:
143
144
  specification_version: 4
144
145
  summary: Send Capistrano deployment status to Slack