capistrano-webhooks 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +52 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +52 -0
- data/Rakefile +1 -0
- data/capistrano-webhooks.gemspec +24 -0
- data/lib/capistrano/webhooks.rb +4 -0
- data/lib/capistrano/webhooks/client.rb +36 -0
- data/lib/capistrano/webhooks/version.rb +5 -0
- data/lib/tasks/webhooks.rake +46 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9847ef1a5737b4c63499fcad5508ec2069f30466
|
4
|
+
data.tar.gz: dfec1087d9ae1dfff6354638909ef4cc6907c426
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 163a9fdbb39b1eb4430cc1a55aa2a28651eee4ece86626a96987f19e74e40f86d7bd066c4b683056717a4d6b8d87b77e0de7b393425c9333978b9528d206408a
|
7
|
+
data.tar.gz: 7f2d3d499c6228d7f4379fb6cd2f7e150a0663c12c00912c9e3839660c684302c157ae40a1cc94c1cf87549e9316d4369341274dffbc62731d74848efbc3390c
|
data/.gitignore
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
.idea
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
/.config
|
5
|
+
/coverage/
|
6
|
+
/InstalledFiles
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/spec/examples.txt
|
10
|
+
/test/tmp/
|
11
|
+
/test/version_tmp/
|
12
|
+
/tmp/
|
13
|
+
|
14
|
+
# Used by dotenv library to load environment variables.
|
15
|
+
# .env
|
16
|
+
|
17
|
+
## Specific to RubyMotion:
|
18
|
+
.dat*
|
19
|
+
.repl_history
|
20
|
+
build/
|
21
|
+
*.bridgesupport
|
22
|
+
build-iPhoneOS/
|
23
|
+
build-iPhoneSimulator/
|
24
|
+
|
25
|
+
## Specific to RubyMotion (use of CocoaPods):
|
26
|
+
#
|
27
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
28
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
29
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
30
|
+
#
|
31
|
+
# vendor/Pods/
|
32
|
+
|
33
|
+
## Documentation cache and generated files:
|
34
|
+
/.yardoc/
|
35
|
+
/_yardoc/
|
36
|
+
/doc/
|
37
|
+
/rdoc/
|
38
|
+
|
39
|
+
## Environment normalization:
|
40
|
+
/.bundle/
|
41
|
+
/vendor/bundle
|
42
|
+
/lib/bundler/man/
|
43
|
+
|
44
|
+
# for a library or gem, you might want to ignore these files since the code is
|
45
|
+
# intended to run in multiple environments; otherwise, check them in:
|
46
|
+
# Gemfile.lock
|
47
|
+
# .ruby-version
|
48
|
+
# .ruby-gemset
|
49
|
+
|
50
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
51
|
+
.rvmrc
|
52
|
+
/Gemfile.lock
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Stanislav Fesenko
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Capistrano::Webhooks
|
2
|
+
|
3
|
+
Webhooks for Capistrano.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile under the 'development' group:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'capistrano-webhooks'
|
11
|
+
```
|
12
|
+
|
13
|
+
Execute:
|
14
|
+
|
15
|
+
```
|
16
|
+
bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Add this to `Capfile`:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'capistrano/webhooks'
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Add this to `deploy.rb` or to stage configuration file.
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
# Example
|
31
|
+
set :webhooks, 'http://example.com': {
|
32
|
+
method: :post, # Request send method. POST by default
|
33
|
+
payload: { user: fetch(:local_user) }, # Data will be sent
|
34
|
+
before: {
|
35
|
+
'deploy:updating': {
|
36
|
+
payload: { par1: 'val1' } # Override data
|
37
|
+
}
|
38
|
+
},
|
39
|
+
after: {
|
40
|
+
'deploy:finishing': {},
|
41
|
+
'deploy:failed': { method: :get } # Override send method
|
42
|
+
}
|
43
|
+
}
|
44
|
+
```
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
1. Fork it ( http://github.com/iamdeuterium/capistrano-webhooks/fork )
|
49
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
50
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
51
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
52
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'capistrano/webhooks/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'capistrano-webhooks'
|
8
|
+
spec.version = Capistrano::Webhooks::VERSION
|
9
|
+
spec.authors = ['Stanislav Fesenko']
|
10
|
+
spec.email = ['iamdeuterium@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Capistrano webhooks'
|
13
|
+
spec.homepage = 'http://iamdeuterium.ru'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_dependency 'faraday'
|
20
|
+
spec.add_dependency 'capistrano'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'bundler'
|
24
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
module Capistrano
|
4
|
+
module Webhooks
|
5
|
+
class Client
|
6
|
+
attr_reader :url, :options
|
7
|
+
|
8
|
+
def initialize(url, options)
|
9
|
+
@url = url
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
return if dry_run?
|
15
|
+
|
16
|
+
connection.send options[:method], url.to_s, options[:payload]
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def dry_run?
|
22
|
+
::Capistrano::Configuration.env.dry_run?
|
23
|
+
end
|
24
|
+
|
25
|
+
def connection
|
26
|
+
Faraday.new do |faraday|
|
27
|
+
faraday.request :multipart
|
28
|
+
faraday.request :url_encoded
|
29
|
+
faraday.options.timeout = 5
|
30
|
+
faraday.options.open_timeout = 5
|
31
|
+
faraday.adapter Faraday.default_adapter
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
namespace :webhooks do
|
2
|
+
namespace :deploy do
|
3
|
+
task :setup do
|
4
|
+
webhooks = fetch(:webhooks)
|
5
|
+
webhooks = {} unless webhooks.is_a?(Hash)
|
6
|
+
|
7
|
+
default_options = { method: :post, payload: {} }
|
8
|
+
global_options = {}
|
9
|
+
webhook_index = 0
|
10
|
+
|
11
|
+
webhooks.each do |url, options|
|
12
|
+
options = default_options.merge options
|
13
|
+
global_options = options.select { |k, _v| default_options.key?(k) }
|
14
|
+
|
15
|
+
%i[before after].each do |hook|
|
16
|
+
case options[hook]
|
17
|
+
when Array
|
18
|
+
options[hook] = Hash[options[hook].each_slice(1).to_a]
|
19
|
+
when String
|
20
|
+
options[hook] = Hash[options[hook], nil]
|
21
|
+
when nil
|
22
|
+
options[hook] = {}
|
23
|
+
end
|
24
|
+
|
25
|
+
options[hook].each do |webhook, opts|
|
26
|
+
webhook_index += 1
|
27
|
+
|
28
|
+
opts ||= {}
|
29
|
+
opts = global_options.merge opts
|
30
|
+
|
31
|
+
task_name = "webhooks:task_#{webhook_index}"
|
32
|
+
Rake::Task.define_task task_name do
|
33
|
+
Capistrano::Webhooks::Client.new(url, opts).run
|
34
|
+
end
|
35
|
+
|
36
|
+
send hook, webhook, task_name
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
stages.each do |stage|
|
45
|
+
after stage, 'webhooks:deploy:setup'
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-webhooks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stanislav Fesenko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
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
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: capistrano
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
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
|
+
description:
|
70
|
+
email:
|
71
|
+
- iamdeuterium@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- capistrano-webhooks.gemspec
|
82
|
+
- lib/capistrano/webhooks.rb
|
83
|
+
- lib/capistrano/webhooks/client.rb
|
84
|
+
- lib/capistrano/webhooks/version.rb
|
85
|
+
- lib/tasks/webhooks.rake
|
86
|
+
homepage: http://iamdeuterium.ru
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.6.4
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Capistrano webhooks
|
110
|
+
test_files: []
|