capistrano-webhook 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -9
- data/capistrano-webhook.gemspec +1 -1
- data/lib/capistrano-webhook.rb +0 -0
- data/lib/capistrano/webhook.rb +10 -33
- data/lib/capistrano/webhook/v2/tasks.rb +33 -0
- data/lib/capistrano/webhook/v3/tasks.rake +27 -0
- data/lib/capistrano/webhook/version.rb +1 -1
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84592ca61d11ed81135da72ac01748f60a10b2c5
|
4
|
+
data.tar.gz: 384c183a5f7cbbef9a6987302247e85eaa996840
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7469ad20dc746e3362c21f021195607035f97352f780df62f5c34f05d8d553c80f80d39c4db4e35c2f7a998b7ba3238f4abe2179894d11bb6d22b6ac3b5a9b26
|
7
|
+
data.tar.gz: cf856439cb715740bc13aa005fb4a50dfc80624e0cacdafc71d2f2e1d9ebd65288fae75359fbea806be57554f1e68c0864adac01035c4ce6c3e5908006b4924d
|
data/README.md
CHANGED
@@ -2,21 +2,29 @@
|
|
2
2
|
|
3
3
|
Simple webhooks for Capistrano deployments.
|
4
4
|
|
5
|
-
|
5
|
+
Supports both Capistrano 2 and 3!
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
Add this line to your application's Gemfile under the 'development' group:
|
10
10
|
|
11
|
-
gem 'capistrano-webhook'
|
11
|
+
gem 'capistrano-webhook'
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
15
15
|
In your application's `deploy.rb` file, set a Capistrano variable called `webhooks` to a hash containing a set of callbacks you wish to run during your deployment. The hash keys should be event names (see supported events below) and they should map to arrays representing webhook arguments to send to Faraday. The first item in each webhook should be a valid Farday HTTP method (`:get`, `:post`, etc will map to `Faraday.get`, and `Faraday.post` respectively). All other arguments will be sent in to the Faraday method as arguments with as a splat.
|
16
16
|
|
17
|
+
In your `Capfile`:
|
18
|
+
|
17
19
|
```
|
18
20
|
require 'capistrano/webhook'
|
19
|
-
|
21
|
+
```
|
22
|
+
|
23
|
+
In your `deploy.rb`:
|
24
|
+
|
25
|
+
For Cap 2:
|
26
|
+
```
|
27
|
+
set :webhooks, do
|
20
28
|
{
|
21
29
|
after_deploy: [
|
22
30
|
[:get, "https://ci.example.com", { sha: fetch(:current_revision), app: fetch(:application), env: fetch(:stage) }]
|
@@ -25,15 +33,25 @@ set(:webhooks) do
|
|
25
33
|
end
|
26
34
|
```
|
27
35
|
|
36
|
+
|
37
|
+
For Cap 3:
|
38
|
+
```
|
39
|
+
set :webhooks, {
|
40
|
+
after_deploy: [
|
41
|
+
[:get, "https://ci.example.com", { sha: fetch(:current_revision), app: fetch(:application), env: fetch(:stage) }]
|
42
|
+
]
|
43
|
+
}
|
44
|
+
```
|
45
|
+
|
28
46
|
In this example, a `GET` request would be issued to `https://ci.example.com?sha=:current_revision&app=:application&env=:stage`
|
29
47
|
|
30
48
|
#### Supported Capistrano Events
|
31
49
|
|
32
50
|
```
|
33
|
-
:before_deploy # runs before 'deploy'
|
34
|
-
:before_deploy_migrations # runs before 'deploy:migrations'
|
35
|
-
:after_deploy # runs after 'deploy'
|
36
|
-
:after_deploy_migrations # runs after 'deploy:migrations'
|
51
|
+
:before_deploy # runs before 'deploy' (Cap 3: 'deploy:started')
|
52
|
+
:before_deploy_migrations # runs before 'deploy:migrations' (Cap 3: 'deploy:migrate')
|
53
|
+
:after_deploy # runs after 'deploy' (Cap 3: 'deploy:finished')
|
54
|
+
:after_deploy_migrations # runs after 'deploy:migrations' (Cap 3: 'deploy:migrate')
|
37
55
|
```
|
38
56
|
|
39
57
|
#### See also:
|
@@ -45,9 +63,9 @@ For `post`, `put`, and `patch` requests, see: https://github.com/lostisland/fara
|
|
45
63
|
## TODO
|
46
64
|
|
47
65
|
* Deeper Faraday support (POST body, headers, etc)
|
48
|
-
* Support for Cap 3
|
66
|
+
* ~~Support for Cap 3~~
|
49
67
|
* Logging enhancements
|
50
|
-
* Support more events, maybe custom events
|
68
|
+
* Support more (all?) events, maybe custom events
|
51
69
|
|
52
70
|
## Contributing
|
53
71
|
|
data/capistrano-webhook.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "faraday"
|
22
|
-
spec.add_dependency "capistrano"
|
22
|
+
spec.add_dependency "capistrano"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.5"
|
25
25
|
spec.add_development_dependency "rake"
|
File without changes
|
data/lib/capistrano/webhook.rb
CHANGED
@@ -1,38 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require '
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
|
2
|
+
|
3
|
+
require 'capistrano/version'
|
4
4
|
require 'faraday'
|
5
|
+
require 'json'
|
5
6
|
|
6
7
|
module Capistrano
|
7
8
|
module Webhook
|
8
|
-
def self.extended(configuration)
|
9
|
-
configuration.load do
|
10
|
-
|
11
|
-
before 'deploy', 'webhook:before_deploy'
|
12
|
-
before 'deploy:migrations', 'webhook:before_deploy_migrations'
|
13
|
-
after 'deploy', 'webhook:after_deploy'
|
14
|
-
after 'deploy:migrations', 'webhook:after_deploy_migrations'
|
15
|
-
|
16
|
-
namespace :webhook do
|
17
|
-
task :before_deploy do
|
18
|
-
do_webhooks_for_event :before_deploy
|
19
|
-
end
|
20
|
-
task :before_deploy_migrations do
|
21
|
-
do_webhooks_for_event :before_deploy_migrations
|
22
|
-
end
|
23
|
-
task :after_deploy do
|
24
|
-
do_webhooks_for_event :after_deploy
|
25
|
-
end
|
26
|
-
task :after_deploy_migrations do
|
27
|
-
do_webhooks_for_event :after_deploy_migrations
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
9
|
def webhooks
|
35
|
-
|
10
|
+
fetch :webhooks, {}
|
36
11
|
end
|
37
12
|
|
38
13
|
def do_webhooks_for_event(event)
|
@@ -61,6 +36,8 @@ module Capistrano
|
|
61
36
|
end
|
62
37
|
end
|
63
38
|
|
64
|
-
if Capistrano::
|
65
|
-
|
66
|
-
|
39
|
+
if defined?(Capistrano::VERSION) && Gem::Version.new(Capistrano::VERSION).release >= Gem::Version.new('3.0.0')
|
40
|
+
load File.expand_path('../webhook/v3/tasks.rake', __FILE__)
|
41
|
+
else
|
42
|
+
require 'capistrano/webhook/v2/tasks'
|
43
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
|
3
|
+
module Capistrano
|
4
|
+
module Webhook
|
5
|
+
def self.extended(configuration)
|
6
|
+
configuration.load do
|
7
|
+
namespace :webhook do
|
8
|
+
task :before_deploy do
|
9
|
+
do_webhooks_for_event :before_deploy
|
10
|
+
end
|
11
|
+
task :before_deploy_migrations do
|
12
|
+
do_webhooks_for_event :before_deploy_migrations
|
13
|
+
end
|
14
|
+
task :after_deploy do
|
15
|
+
do_webhooks_for_event :after_deploy
|
16
|
+
end
|
17
|
+
task :after_deploy_migrations do
|
18
|
+
do_webhooks_for_event :after_deploy_migrations
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
before 'deploy', 'webhook:before_deploy'
|
23
|
+
before 'deploy:migrations', 'webhook:before_deploy_migrations'
|
24
|
+
after 'deploy', 'webhook:after_deploy'
|
25
|
+
after 'deploy:migrations', 'webhook:after_deploy_migrations'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if Capistrano::Configuration.instance
|
32
|
+
Capistrano::Configuration.instance.extend(Capistrano::Webhook)
|
33
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
namespace :webhook do
|
2
|
+
task :before_deploy do
|
3
|
+
on roles(:db) do
|
4
|
+
Capistrano::Webhook.new.do_webhooks_for_event :before_deploy
|
5
|
+
end
|
6
|
+
end
|
7
|
+
task :before_deploy_migrations do
|
8
|
+
on roles(:db) do
|
9
|
+
Capistrano::Webhook.new.do_webhooks_for_event :before_deploy_migrations
|
10
|
+
end
|
11
|
+
end
|
12
|
+
task :after_deploy do
|
13
|
+
on roles(:db) do
|
14
|
+
Capistrano::Webhook.new.do_webhooks_for_event :after_deploy
|
15
|
+
end
|
16
|
+
end
|
17
|
+
task :after_deploy_migrations do
|
18
|
+
on roles(:db) do
|
19
|
+
Capistrano::Webhook.new.do_webhooks_for_event :after_deploy_migrations
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
before 'deploy:started', 'webhook:before_deploy'
|
24
|
+
before 'deploy:migrate', 'webhook:before_deploy_migrations'
|
25
|
+
after 'deploy:finished', 'webhook:after_deploy'
|
26
|
+
after 'deploy:migrate', 'webhook:after_deploy_migrations'
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-webhook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Hammond
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: capistrano
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,7 +79,10 @@ files:
|
|
79
79
|
- README.md
|
80
80
|
- Rakefile
|
81
81
|
- capistrano-webhook.gemspec
|
82
|
+
- lib/capistrano-webhook.rb
|
82
83
|
- lib/capistrano/webhook.rb
|
84
|
+
- lib/capistrano/webhook/v2/tasks.rb
|
85
|
+
- lib/capistrano/webhook/v3/tasks.rake
|
83
86
|
- lib/capistrano/webhook/version.rb
|
84
87
|
homepage: http://github.com/andrhamm
|
85
88
|
licenses:
|
@@ -101,9 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
104
|
version: '0'
|
102
105
|
requirements: []
|
103
106
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.2.
|
107
|
+
rubygems_version: 2.2.2
|
105
108
|
signing_key:
|
106
109
|
specification_version: 4
|
107
110
|
summary: Simple webhooks for Capistrano deployments.
|
108
111
|
test_files: []
|
109
|
-
has_rdoc:
|