capistrano-flowdock 0.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 +17 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +1 -0
- data/capistrano-flowdock.gemspec +26 -0
- data/lib/capistrano-flowdock.rb +1 -0
- data/lib/capistrano/flowdock.rb +92 -0
- data/lib/capistrano/flowdock/version.rb +5 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4b71358d056f8e4c37b7283672100ca57c4c915e
|
4
|
+
data.tar.gz: e5825608765f648c51811887f2533f97cf4c070a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c2a718c219f411156841a841c8baee667d312a750cd5a1b1f6dbfdff1b81860eaf0e742095a71d641f843ed259faa54c73e42039caeae2a9bec2e2d53102c033
|
7
|
+
data.tar.gz: 7f1a6d7eb5348ce21509f810f428aef5dd6b7a3f110f4756e25e8bcb4a367af64fc7807015540c37b497c096ea816d23a1ef241ab7c8c57d6ee1d8ae0490a243
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Rally Software Development Corp.
|
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,38 @@
|
|
1
|
+
# Capistrano::Flowdock
|
2
|
+
|
3
|
+
Notify Flowdock flows about Capistrano deployments
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'capistrano-flowdock'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install capistrano-flowdock
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Load `capistrano-flowdock` in Capistrano `deploy.rb` file and set Flowdock API
|
22
|
+
tokens and project configuration.
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
require 'capistrano-flowdock'
|
26
|
+
|
27
|
+
set :flowdock_api_token, "_YOUR_API_TOKEN_HERE"
|
28
|
+
set :flowdock_project_name, "My project" # Optional, defaults to application
|
29
|
+
set :flowdock_deploy_tags, ["deploy"] # Optional, defaults to ["deploy"]
|
30
|
+
```
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -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
|
+
require 'capistrano/flowdock/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "capistrano-flowdock"
|
8
|
+
spec.version = Capistrano::Flowdock::VERSION
|
9
|
+
spec.authors = ["Ville Lautanala"]
|
10
|
+
spec.email = ["lautis@gmail.com"]
|
11
|
+
spec.description = %q{Notify Flowdock flows about git-based Capistrano deployments}
|
12
|
+
spec.summary = %q{Flowdock notifier for Capistrano}
|
13
|
+
spec.homepage = "https://flowdock.com/help/capistrano"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "flowdock", "~> 0.3.1"
|
22
|
+
spec.add_runtime_dependency "capistrano", "~> 2.0"
|
23
|
+
spec.add_runtime_dependency "grit", "~> 2.4"
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'capistrano/flowdock'
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require "capistrano/flowdock/version"
|
2
|
+
|
3
|
+
require 'capistrano'
|
4
|
+
require 'flowdock'
|
5
|
+
require 'digest/md5'
|
6
|
+
require 'cgi'
|
7
|
+
|
8
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
9
|
+
|
10
|
+
namespace :flowdock do
|
11
|
+
task :read_current_deployed_branch do
|
12
|
+
current_branch = capture("cat #{current_path}/BRANCH").chomp rescue "master"
|
13
|
+
set :current_branch, current_branch
|
14
|
+
end
|
15
|
+
|
16
|
+
task :save_deployed_branch do
|
17
|
+
begin
|
18
|
+
run "echo '#{source.head.chomp}' > #{current_path}/BRANCH"
|
19
|
+
rescue => e
|
20
|
+
puts "Flowdock: error in saving deployed branch information: #{e.to_s}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
task :set_flowdock_api do
|
25
|
+
set :flowdock_deploy_env, fetch(:stage, fetch(:rails_env, ENV["RAILS_ENV"] || "production"))
|
26
|
+
begin
|
27
|
+
require 'grit'
|
28
|
+
set :repo, Grit::Repo.new(".")
|
29
|
+
config = Grit::Config.new(repo)
|
30
|
+
rescue LoadError => e
|
31
|
+
puts "Flowdock: you need to have Grit gem installed: #{e.to_s}"
|
32
|
+
rescue => e
|
33
|
+
puts "Flowdock: error in fetching your git repository information: #{e.to_s}"
|
34
|
+
end
|
35
|
+
|
36
|
+
begin
|
37
|
+
flows = Array(flowdock_api_token).map do |api_token|
|
38
|
+
::Flowdock::Flow.new(:api_token => api_token,
|
39
|
+
:source => "Capistrano deployment", :project => flowdock_project_name,
|
40
|
+
:from => {:name => config["user.name"], :address => config["user.email"]})
|
41
|
+
end
|
42
|
+
set :flowdock_api, flows
|
43
|
+
rescue => e
|
44
|
+
puts "Flowdock: error in configuring Flowdock API: #{e.to_s}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
task :notify_deploy_finished do
|
49
|
+
# send message to the flow
|
50
|
+
begin
|
51
|
+
flowdock_api.each do |flow|
|
52
|
+
flow.push_to_team_inbox(:format => "html",
|
53
|
+
:subject => "#{flowdock_project_name} deployed with branch #{branch} on ##{flowdock_deploy_env}",
|
54
|
+
:content => notification_message,
|
55
|
+
:tags => ["deploy", "#{flowdock_deploy_env}"] | flowdock_deploy_tags)
|
56
|
+
end unless dry_run
|
57
|
+
rescue => e
|
58
|
+
puts "Flowdock: error in sending notification to your flow: #{e.to_s}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def notification_message
|
63
|
+
if branch == current_branch
|
64
|
+
message = "<p>The following changes were just deployed to #{flowdock_deploy_env}:</p>"
|
65
|
+
commits = repo.commits_between(previous_revision, current_revision).reverse
|
66
|
+
|
67
|
+
unless commits.empty?
|
68
|
+
commits.each do |c|
|
69
|
+
short, long = c.message.split(/\n+/, 2)
|
70
|
+
message << "\n<div style=\"margin-bottom: 10px\"><div style=\"height:30px;width:30px;float:left;margin-right:5px;\"><img src=\"https://secure.gravatar.com/avatar/#{Digest::MD5::hexdigest(c.author.email.downcase)}?s=30\" /></div>"
|
71
|
+
message << "<div style=\"padding-left: 35px;\">#{CGI.escapeHTML(short)}<br/>"
|
72
|
+
if long
|
73
|
+
long.gsub!(/\n/, '<br />')
|
74
|
+
message << '<p style="margin:5px 0px; padding: 0 5px; border-left: 3px solid #ccc">' + long + '</p>'
|
75
|
+
end
|
76
|
+
message << "<span style=\"font-size: 90%; color: #333\"><code>#{c.id_abbrev}</code> <a href=\"mailto:#{CGI.escapeHTML(c.author.email)}\">#{CGI.escapeHTML(c.author.name)}</a> on #{c.authored_date.strftime("%b %d, %H:%M")}</span></div></div>"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
else
|
80
|
+
message = "Branch #{source.head} was deployed to #{flowdock_deploy_env}. Previously deployed branch was #{current_branch}."
|
81
|
+
end
|
82
|
+
message
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
before "deploy:update_code", "flowdock:read_current_deployed_branch"
|
87
|
+
before "flowdock:notify_deploy_finished", "flowdock:set_flowdock_api"
|
88
|
+
["deploy", "deploy:migrations"].each do |task|
|
89
|
+
after task, "flowdock:notify_deploy_finished"
|
90
|
+
after task, "flowdock:save_deployed_branch"
|
91
|
+
end
|
92
|
+
end
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-flowdock
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ville Lautanala
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: flowdock
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.3.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.3.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: capistrano
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: grit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.4'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
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: Notify Flowdock flows about git-based Capistrano deployments
|
84
|
+
email:
|
85
|
+
- lautis@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- capistrano-flowdock.gemspec
|
96
|
+
- lib/capistrano-flowdock.rb
|
97
|
+
- lib/capistrano/flowdock.rb
|
98
|
+
- lib/capistrano/flowdock/version.rb
|
99
|
+
homepage: https://flowdock.com/help/capistrano
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.0.3
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: Flowdock notifier for Capistrano
|
123
|
+
test_files: []
|