capistrano-slackify 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +5 -0
- data/CONTRIBUTING.md +13 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +8 -0
- data/capistrano-slackify.gemspec +26 -0
- data/lib/capistrano/slackify.rb +2 -0
- data/lib/capistrano/tasks/slackify.cap +25 -0
- data/lib/slackify.rb +54 -0
- data/spec/lib/slackify_spec.rb +22 -0
- data/spec/spec_helper.rb +7 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7f43d21b28dc2237a8c389c9925bde9e9f96947e
|
4
|
+
data.tar.gz: 8ca460ea89937d3b18074e6faea7a7d7280adda2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 95447efe53eb4ad20865629e3d800e93cea36c20242b849c4e62f54d2a994c7bdf5f22a61c23f211508dcdc6a49cf339d95f354bfa9ad6b99695322daa20fbeb
|
7
|
+
data.tar.gz: 46a2a7625fbee81dd9f677f97d4830d9eb96b528a72b11ca8fda0e11ccccaf9f55fc19f3539c1c46a89e0b93305364e36cb534b6fe8bbf2f1272039dc5dabf06
|
data/.gitignore
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
## Contributing
|
2
|
+
|
3
|
+
We love to get pull requests, here's how we like to work:
|
4
|
+
|
5
|
+
- Open a pull request. Before you start coding, let's make sure we're on the same page.
|
6
|
+
- Fork the repo.
|
7
|
+
- Run the tests. We only take pull requests with passing tests: `bundle && rake`
|
8
|
+
- Add a test for your change. Only refactoring and documentation changes require no new tests.
|
9
|
+
- Make the test pass, following the conventions you see used in the source already.
|
10
|
+
- If you have made a number of commits, squash them before pushing with.
|
11
|
+
- Push to your fork and update your pull request.
|
12
|
+
- We may suggest some changes or improvements or alternatives.
|
13
|
+
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 OnTheBeach Ltd
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Capistrano Slackify
|
2
|
+
|
3
|
+
Publish deploy notifications to [Slack](https://slack.com) - for [Capistrano v3](https://github.com/capistrano/capistrano).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'capistrano-slackify'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install capistrano-slackify
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Require the gem in your `Capfile`:
|
22
|
+
|
23
|
+
require 'capistrano/slackfiy'
|
24
|
+
|
25
|
+
And then set the required variables in `config/deploy.rb`:
|
26
|
+
|
27
|
+
set :slack_subdomain, 'my_slack_subdomain'
|
28
|
+
set :slack_token, 'my_slack_token'
|
29
|
+
|
30
|
+
Ensure that you have enabled the [incoming webhooks integration](https://api.slack.com/).
|
31
|
+
|
32
|
+
The task will run automatically on deploy, or can be run manually using:
|
33
|
+
|
34
|
+
`bundle exec cap production slack:notify`
|
35
|
+
|
36
|
+
By default, this will publish something along the lines of:
|
37
|
+
|
38
|
+
Revision 64a3c1de of my_app deployed to production by seenmyfate
|
39
|
+
|
40
|
+
### Customisation
|
41
|
+
|
42
|
+
Any of the defaults can be over-ridden in `config/deploy.rb`:
|
43
|
+
|
44
|
+
set :slack_channel, '#devops'
|
45
|
+
set :slack_username, 'Deploybot'
|
46
|
+
set :slack_text, -> { "Uh-oh, #{local_user} just deployed" }
|
47
|
+
set :slack_emoji, ':trollface:'
|
48
|
+
|
49
|
+
### Copyright
|
50
|
+
|
51
|
+
Copyright (c) 2014 OnTheBeach Ltd. See LICENSE.txt for
|
52
|
+
further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'capistrano-slackify'
|
7
|
+
spec.version = '1.0.0'
|
8
|
+
spec.authors = ['seenmyfate']
|
9
|
+
spec.email = ['seenmyfate@gmail.com']
|
10
|
+
spec.summary = %q{Publish deployment notifications to Slack via the incoming webhooks integration}
|
11
|
+
spec.description = %q{Publish deployment notifications to Slack via the incoming webhooks integration}
|
12
|
+
spec.homepage = 'https://github.com/onthebeach/capistrano-slackify'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_runtime_dependency 'capistrano', '>= 3.1.0'
|
21
|
+
spec.add_runtime_dependency 'yajl-ruby'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :slack do
|
2
|
+
desc 'Notify Slack of a deployment via the incoming webhooks integration - ' \
|
3
|
+
':slack_subdomain and :slack_token must be set'
|
4
|
+
task :notify do
|
5
|
+
run_locally do
|
6
|
+
info 'Notifying Slack of deploy'
|
7
|
+
execute :curl, '-X POST',
|
8
|
+
'--data-urlencode', fetch(:slack_payload),
|
9
|
+
fetch(:slack_url)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
after 'deploy:finished', 'slack:notify'
|
14
|
+
end
|
15
|
+
|
16
|
+
namespace :load do
|
17
|
+
task :defaults do
|
18
|
+
set :slack_channel, '#general'
|
19
|
+
set :slack_username, 'Capistrano'
|
20
|
+
set :slack_text, -> { slack_text }
|
21
|
+
set :slack_emoji, ':ghost:'
|
22
|
+
set :slack_payload, -> { "'payload=#{slack_payload}'" }
|
23
|
+
set :slack_url, -> { slack_url }
|
24
|
+
end
|
25
|
+
end
|
data/lib/slackify.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'yajl/json_gem'
|
3
|
+
module Slackify
|
4
|
+
|
5
|
+
class URL
|
6
|
+
|
7
|
+
def initialize(subdomain, token)
|
8
|
+
@subdomain, @token = subdomain, token
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
uri.to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def uri
|
18
|
+
@uri ||= URI(
|
19
|
+
"https://#{@subdomain}.slack.com/services/hooks/incoming-webhook?token=#{@token}"
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module Payload
|
25
|
+
|
26
|
+
def slack_payload
|
27
|
+
{
|
28
|
+
channel: fetch(:slack_channel),
|
29
|
+
username: fetch(:slack_username),
|
30
|
+
text: fetch(:slack_text),
|
31
|
+
icon_emoji: fetch(:slack_emoji)
|
32
|
+
}.to_json
|
33
|
+
end
|
34
|
+
|
35
|
+
def slack_text
|
36
|
+
"Revision #{fetch(:current_revision, fetch(:branch))} of " \
|
37
|
+
"#{fetch(:application)} deployed to #{fetch(:stage)} by #{local_user}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def slack_url
|
41
|
+
URL.new(slack_subdomain, slack_token).to_s
|
42
|
+
end
|
43
|
+
|
44
|
+
def slack_subdomain
|
45
|
+
fetch(:slack_subdomain) { fail ':slack_subdomain is not set' }
|
46
|
+
end
|
47
|
+
|
48
|
+
def slack_token
|
49
|
+
fetch(:slack_token) { fail ':slack_token is not set' }
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
self.extend(Slackify::Payload)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Slackify
|
4
|
+
describe URL do
|
5
|
+
let(:url) { URL.new(subdomain, token) }
|
6
|
+
let(:subdomain) { 'me' }
|
7
|
+
let(:token) { 'abc123' }
|
8
|
+
|
9
|
+
describe '.new' do
|
10
|
+
it 'takes a subdomain and a token' do
|
11
|
+
expect(url)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#to_s' do
|
16
|
+
it 'returns the url as a string' do
|
17
|
+
expect(url.to_s).
|
18
|
+
to eq 'https://me.slack.com/services/hooks/incoming-webhook?token=abc123'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-slackify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- seenmyfate
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: yajl-ruby
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Publish deployment notifications to Slack via the incoming webhooks integration
|
84
|
+
email:
|
85
|
+
- seenmyfate@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- CONTRIBUTING.md
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- capistrano-slackify.gemspec
|
98
|
+
- lib/capistrano/slackify.rb
|
99
|
+
- lib/capistrano/tasks/slackify.cap
|
100
|
+
- lib/slackify.rb
|
101
|
+
- spec/lib/slackify_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
homepage: https://github.com/onthebeach/capistrano-slackify
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.2.2
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Publish deployment notifications to Slack via the incoming webhooks integration
|
127
|
+
test_files:
|
128
|
+
- spec/lib/slackify_spec.rb
|
129
|
+
- spec/spec_helper.rb
|
130
|
+
has_rdoc:
|