slackistrano 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +65 -0
- data/Rakefile +9 -0
- data/lib/slackistrano/tasks/slack.rake +49 -0
- data/lib/slackistrano/version.rb +3 -0
- data/lib/slackistrano.rb +16 -0
- data/slackistrano.gemspec +22 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 716e9f3712c4c0bc15c6eba80a712c7ae6d59a1d
|
4
|
+
data.tar.gz: b8b88f167551b83dc3853597a323887c147412d7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e2445367296595c3c7942b08e78fe03c85dbc57a511618f56ede066bc4be15fbe641db8096659e24cbcdbb18380f7744bc418bb9559fa47662bc859c67554b3
|
7
|
+
data.tar.gz: 21b0a20d303c52c7d87c8a69079e03b8c8006c9674b748304098ad7a55a7742537b03de9841fbd71f6abf1b6f316fc98c12688e506114e58d6f6b0e7a2a20877
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Philip Hallstrom
|
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,65 @@
|
|
1
|
+
# Slackistrano
|
2
|
+
|
3
|
+
Send notifications to [Slack](https://slack.com) about [Capistrano](http://www.capistranorb.com) deployments.
|
4
|
+
|
5
|
+
If you need Capistrano v2 support, check out [capistrano-slack](https://github.com/j-mcnally/capistrano-slack).
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
- Capistrano >= 3
|
10
|
+
- Ruby >= 1.9
|
11
|
+
- A Slack account
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
gem 'slackistrano'
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
## Configuration
|
24
|
+
|
25
|
+
Set up an "Incoming WebHooks" integration in Slack. Make a note
|
26
|
+
of the token as you'll need it later.
|
27
|
+
|
28
|
+
Require the library in your application's Capfile:
|
29
|
+
|
30
|
+
require 'slackistrano'
|
31
|
+
|
32
|
+
Set your team and token in your application's config/deploy.rb:
|
33
|
+
|
34
|
+
set :slack_team, "supremegolf"
|
35
|
+
set :slack_token, "xxxxxxxxxxxxxxxxxxxxxxxx"
|
36
|
+
|
37
|
+
Optionally, override the other slack settings:
|
38
|
+
|
39
|
+
set :slack_icon_url, ->{ "http://gravatar.com/avatar/885e1c523b7975c4003de162d8ee8fee?r=g&s=40" }
|
40
|
+
set :slack_channel, ->{ "#general" }
|
41
|
+
set :slack_username, ->{ "Slackistrano" }
|
42
|
+
|
43
|
+
Test your setup by running:
|
44
|
+
|
45
|
+
$ cap production slack:deploy:starting
|
46
|
+
$ cap production slack:deploy:finished
|
47
|
+
|
48
|
+
## Usage
|
49
|
+
|
50
|
+
Deploy your application like normal and you should see messages in the channel
|
51
|
+
you specified.
|
52
|
+
|
53
|
+
## TODO
|
54
|
+
|
55
|
+
- Add tests.
|
56
|
+
- Notify about incorrect configuration settings.
|
57
|
+
- Notify about unsuccessfull HTTP POSTs.
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
1. Fork it
|
62
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
|
2
|
+
namespace :slack do
|
3
|
+
namespace :deploy do
|
4
|
+
task :starting do
|
5
|
+
run_locally do
|
6
|
+
text = "#{ENV['USER'] || ENV['USERNAME']} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}."
|
7
|
+
Slackistrano.post(
|
8
|
+
team: fetch(:slack_team),
|
9
|
+
token: fetch(:slack_token),
|
10
|
+
payload: {
|
11
|
+
channel: fetch(:slack_channel),
|
12
|
+
username: fetch(:slack_username),
|
13
|
+
icon_url: fetch(:slack_icon_url),
|
14
|
+
text: text
|
15
|
+
}
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
task :finished do
|
21
|
+
run_locally do
|
22
|
+
text = "#{ENV['USER'] || ENV['USERNAME']} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}."
|
23
|
+
Slackistrano.post(
|
24
|
+
team: fetch(:slack_team),
|
25
|
+
token: fetch(:slack_token),
|
26
|
+
payload: {
|
27
|
+
channel: fetch(:slack_channel),
|
28
|
+
username: fetch(:slack_username),
|
29
|
+
icon_url: fetch(:slack_icon_url),
|
30
|
+
text: text
|
31
|
+
}
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
before 'deploy:starting', 'slack:deploy:starting'
|
39
|
+
after 'deploy:finished', 'slack:deploy:finished'
|
40
|
+
|
41
|
+
namespace :load do
|
42
|
+
task :defaults do
|
43
|
+
set :slack_team, ->{ nil } # If URL is 'team.slack.com', value is 'team'. Required.
|
44
|
+
set :slack_token, ->{ nil } # Token from Incoming WebHooks. Required.
|
45
|
+
set :slack_icon_url, ->{ "http://gravatar.com/avatar/885e1c523b7975c4003de162d8ee8fee?r=g&s=40" }
|
46
|
+
set :slack_channel, ->{ "#general" }
|
47
|
+
set :slack_username, ->{ "Capistrano" }
|
48
|
+
end
|
49
|
+
end
|
data/lib/slackistrano.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'slackistrano/version'
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
load File.expand_path("../slackistrano/tasks/slack.rake", __FILE__)
|
6
|
+
|
7
|
+
module Slackistrano
|
8
|
+
def self.post(team: nil, token: nil, payload: {})
|
9
|
+
uri = URI("https://#{team}.slack.com/services/hooks/incoming-webhook")
|
10
|
+
res = Net::HTTP.post_form(uri, 'token' => token, 'payload' => payload.to_json)
|
11
|
+
rescue => e
|
12
|
+
puts "There was an error notifying Slack."
|
13
|
+
puts e.inspect
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'slackistrano/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "slackistrano"
|
8
|
+
gem.version = Slackistrano::VERSION
|
9
|
+
gem.authors = ["Philip Hallstrom"]
|
10
|
+
gem.email = ["philip@supremegolf.com"]
|
11
|
+
gem.description = %q{}
|
12
|
+
gem.summary = %q{}
|
13
|
+
gem.homepage = "https://github.com/supremegolf/slackistrano"
|
14
|
+
gem.license = 'MIT'
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.add_dependency('json')
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slackistrano
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Philip Hallstrom
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: ''
|
28
|
+
email:
|
29
|
+
- philip@supremegolf.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- Gemfile
|
35
|
+
- LICENSE.txt
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- lib/slackistrano.rb
|
39
|
+
- lib/slackistrano/tasks/slack.rake
|
40
|
+
- lib/slackistrano/version.rb
|
41
|
+
- slackistrano.gemspec
|
42
|
+
homepage: https://github.com/supremegolf/slackistrano
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata: {}
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 2.1.11
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: ''
|
66
|
+
test_files: []
|