capistrano-bearychat 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +70 -0
- data/Rakefile +3 -0
- data/capistrano-bearychat.gemspec +25 -0
- data/lib/capistrano-bearychat.rb +0 -0
- data/lib/capistrano/bearychat.rb +20 -0
- data/lib/capistrano/tasks/bearychat.rake +71 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 77a6e6e3cf614e6a9df90a545b9e26fae46c383d
|
4
|
+
data.tar.gz: d39df11929be25aa6f6914184b07b1fe3544d84c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e065a92518089ea396dbce01331f3e892921c8b6185ff3a76556f5e79ea5987a082f48bb05dceb82881f111445d59faca5980419dda2dd064984b95d44092811
|
7
|
+
data.tar.gz: 75a48a34f6b953cfc775cc4ea2550ab12bc02525adea7006a1aae53a5bbe0fcaf28ce9c6d3b5c0ec1d645ab9f311d119d3e15361654cd40846b1c46c10e1cb20
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Kai Chen
|
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,70 @@
|
|
1
|
+
# Capistrano::Bearychat
|
2
|
+
|
3
|
+
Send notifications to [Bearychat](https://bearychat.com) about [Capistrano v3](http://www.capistranorb.com) deployments. Inspired by [slackistrano](https://github.com/supremegolf/slackistrano).
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
- Capistrano >= 3.1.0
|
8
|
+
- Ruby >= 2.0
|
9
|
+
- A Bearychat account
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem "capistrano", "~> 3.1"
|
16
|
+
gem "capistrano-bearychat", require: false
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
## Configuration
|
23
|
+
|
24
|
+
To notify a channel in Bearychat when you deploy, Using *Incoming WebHooks* integration, offering more options but requires one of the five free integrations.
|
25
|
+
|
26
|
+
You need to enable the integration inside Bearychat and get the incoming webhook url that will be needed later.
|
27
|
+
|
28
|
+
Require the library in your application's Capfile:
|
29
|
+
|
30
|
+
require 'capistrano/bearychat'
|
31
|
+
|
32
|
+
You need to set your webhook url in your application's config/deploy.rb:
|
33
|
+
|
34
|
+
set :bearychat_webhook, "https://hook.bearychat.com/XXXX/XXX/XXXXX"
|
35
|
+
|
36
|
+
Optionally, override the other settings:
|
37
|
+
|
38
|
+
set :bearychat_channel, -> { '#general' }
|
39
|
+
set :bearychat_using_markdown, ->{ false } # Set to true to treat text as markdown.
|
40
|
+
set :bearychat_channel_starting, -> { nil } # Channel to post to. Optional. Defaults to :bearychat_channel.
|
41
|
+
set :bearychat_channel_finished, -> { nil } # Channel to post to. Optional. Defaults to :bearychat_channel.
|
42
|
+
set :bearychat_channel_failed, -> { nil } # Channel to post to. Optional. Defaults to :bearychat_channel.
|
43
|
+
set :bearychat_run_starting, -> { true }
|
44
|
+
set :bearychat_run_finished, -> { true }
|
45
|
+
set :bearychat_run_failed, -> { true }
|
46
|
+
set :bearychat_msg_starting, -> { "#{ENV['USER'] || ENV['USERNAME']} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}" }
|
47
|
+
set :bearychat_msg_finished, -> { "#{ENV['USER'] || ENV['USERNAME']} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}" }
|
48
|
+
set :bearychat_msg_failed, -> { "#{ENV['USER'] || ENV['USERNAME']} failed to deploy branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}" }
|
49
|
+
|
50
|
+
**Note**: You may wish to disable one of the notifications if another service (ex:
|
51
|
+
Honeybadger) also displays a deploy notification.
|
52
|
+
|
53
|
+
Test your setup by running:
|
54
|
+
|
55
|
+
$ cap production bearychat:deploy:starting
|
56
|
+
$ cap production bearychat:deploy:finished
|
57
|
+
$ cap production bearychat:deploy:failed
|
58
|
+
|
59
|
+
## Usage
|
60
|
+
|
61
|
+
Deploy your application like normal and you should see messages in the channel
|
62
|
+
you specified.
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
1. Fork it
|
67
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
68
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
69
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
70
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: 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 |gem|
|
6
|
+
gem.name = "capistrano-bearychat"
|
7
|
+
gem.version = "1.0"
|
8
|
+
gem.authors = ["Kai Chen"]
|
9
|
+
gem.email = ["kai@thekaiway.com"]
|
10
|
+
gem.description = %q{Send notifications to Bearychat about Capistrano deployments.}
|
11
|
+
gem.summary = %q{Send notifications to Bearychat about Capistrano deployments.}
|
12
|
+
gem.homepage = "https://github.com/kaichen/capistrano-bearychat"
|
13
|
+
gem.license = 'MIT'
|
14
|
+
|
15
|
+
gem.required_ruby_version = '>= 2.0.0'
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
|
22
|
+
gem.add_dependency 'capistrano', '>= 3.0.1'
|
23
|
+
gem.add_dependency 'json'
|
24
|
+
gem.add_development_dependency 'rake'
|
25
|
+
end
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
load File.expand_path("../tasks/bearychat.rake", __FILE__)
|
5
|
+
|
6
|
+
module Capistrano
|
7
|
+
module Bearychat
|
8
|
+
extend self
|
9
|
+
|
10
|
+
def post(webhook, payload: {})
|
11
|
+
if webhook.nil?
|
12
|
+
raise ArgumentError, "Please set bearychat_webhook in your deploy.rb file"
|
13
|
+
end
|
14
|
+
Net::HTTP.post_form(URI(webhook), "payload" => payload.to_json)
|
15
|
+
rescue => e
|
16
|
+
puts "There was an error notifying Bearychat."
|
17
|
+
puts e.inspect
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
namespace :bearychat do
|
2
|
+
namespace :deploy do
|
3
|
+
task :starting do
|
4
|
+
if fetch(:bearychat_run_starting)
|
5
|
+
run_locally do
|
6
|
+
Capistrano::Bearychat.post(
|
7
|
+
fetch(:bearychat_webhook),
|
8
|
+
payload: {
|
9
|
+
channel: fetch(:bearychat_channel_starting) || fetch(:bearychat_channel),
|
10
|
+
text: fetch(:bearychat_msg_starting),
|
11
|
+
using_markdown: fetch(:bearychat_using_markdown)
|
12
|
+
}
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
task :finished do
|
19
|
+
if fetch(:bearychat_run_finished)
|
20
|
+
run_locally do
|
21
|
+
Capistrano::Bearychat.post(
|
22
|
+
fetch(:bearychat_webhook),
|
23
|
+
payload: {
|
24
|
+
channel: fetch(:bearychat_channel_finished) || fetch(:bearychat_channel),
|
25
|
+
text: fetch(:bearychat_msg_finished),
|
26
|
+
using_markdown: fetch(:bearychat_using_markdown)
|
27
|
+
}
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
task :failed do
|
34
|
+
if fetch(:bearychat_run_failed)
|
35
|
+
run_locally do
|
36
|
+
Capistrano::Bearychat.post(
|
37
|
+
fetch(:bearychat_webhook),
|
38
|
+
payload: {
|
39
|
+
channel: fetch(:bearychat_channel_failed) || fetch(:bearychat_channel),
|
40
|
+
text: fetch(:bearychat_msg_failed),
|
41
|
+
using_markdown: fetch(:bearychat_using_markdown)
|
42
|
+
}
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
after 'deploy:starting', 'bearychat:deploy:starting'
|
52
|
+
after 'deploy:finished', 'bearychat:deploy:finished'
|
53
|
+
after 'deploy:failed', 'bearychat:deploy:failed'
|
54
|
+
|
55
|
+
namespace :load do
|
56
|
+
task :defaults do
|
57
|
+
set :bearychat_webhook, ->{ nil } # Incoming WebHook URL.
|
58
|
+
set :bearychat_using_markdown, ->{ false } # Set to true to treat text as markdown.
|
59
|
+
|
60
|
+
set :bearychat_channel, -> { nil } # Channel to post to. Optional. Defaults to WebHook setting.
|
61
|
+
set :bearychat_channel_starting, -> { nil } # Channel to post to. Optional. Defaults to :bearychat_channel.
|
62
|
+
set :bearychat_channel_finished, -> { nil } # Channel to post to. Optional. Defaults to :bearychat_channel.
|
63
|
+
set :bearychat_channel_failed, -> { nil } # Channel to post to. Optional. Defaults to :bearychat_channel.
|
64
|
+
set :bearychat_run_starting, -> { true } # Set to false to disable starting message.
|
65
|
+
set :bearychat_run_finished, -> { true } # Set to false to disable finished message.
|
66
|
+
set :bearychat_run_failed, -> { true } # Set to false to disable failure message.
|
67
|
+
set :bearychat_msg_starting, -> { "#{ENV['USER'] || ENV['USERNAME']} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
68
|
+
set :bearychat_msg_finished, -> { "#{ENV['USER'] || ENV['USERNAME']} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
69
|
+
set :bearychat_msg_failed, -> { "#{ENV['USER'] || ENV['USERNAME']} failed to deploy branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
70
|
+
end
|
71
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-bearychat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kai Chen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-13 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.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
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: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Send notifications to Bearychat about Capistrano deployments.
|
56
|
+
email:
|
57
|
+
- kai@thekaiway.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- capistrano-bearychat.gemspec
|
68
|
+
- lib/capistrano-bearychat.rb
|
69
|
+
- lib/capistrano/bearychat.rb
|
70
|
+
- lib/capistrano/tasks/bearychat.rake
|
71
|
+
homepage: https://github.com/kaichen/capistrano-bearychat
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 2.0.0
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.4.5
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Send notifications to Bearychat about Capistrano deployments.
|
95
|
+
test_files: []
|