lita-ey-deploy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.rspec +1 -0
- data/.travis.yml +13 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +103 -0
- data/LICENSE +19 -0
- data/README.md +47 -0
- data/Rakefile +6 -0
- data/lib/lita/handlers/ey_deploy.rb +111 -0
- data/lib/lita-ey-deploy.rb +1 -0
- data/lita-ey-deploy.gemspec +25 -0
- data/spec/lita/handlers/ey_deploy_spec.rb +6 -0
- data/spec/spec_helper.rb +11 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c57c5e1dc6b698942ab680084032f8c092ec7f17
|
4
|
+
data.tar.gz: 90664fab373e9898e8ddea68ee7344ff8583418d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 25d02ce00dc8506408c8cdc45f919b9e7caad6eeda1952a04416eec7e3ba09c12a94919883a8a25e5e652b600fd3be2b973547c56ee09c6bbdc00cfcfce4124b
|
7
|
+
data.tar.gz: f60bc4e91c04cbb26f1e3b014de4c983ddbe5711a9a75a9f703e602fcdbc1ebf5558e52d4f8604616a9bb8697095d61ca5a165dde21b6522e8a262ba2c7fe1b8
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
-f documentation --color
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lita-ey-deploy (0.0.1)
|
5
|
+
engineyard
|
6
|
+
lita (>= 3.2.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.3.6)
|
12
|
+
coveralls (0.7.0)
|
13
|
+
multi_json (~> 1.3)
|
14
|
+
rest-client
|
15
|
+
simplecov (>= 0.7)
|
16
|
+
term-ansicolor
|
17
|
+
thor
|
18
|
+
diff-lcs (1.2.5)
|
19
|
+
docile (1.1.3)
|
20
|
+
engineyard (2.3.3)
|
21
|
+
engineyard-cloud-client (~> 1.0.16)
|
22
|
+
engineyard-serverside-adapter (= 2.2.0)
|
23
|
+
escape (~> 0.0.4)
|
24
|
+
highline (~> 1.6.1)
|
25
|
+
launchy (~> 2.1)
|
26
|
+
net-ssh (~> 2.7)
|
27
|
+
rest-client (~> 1.6.0)
|
28
|
+
engineyard-cloud-client (1.0.16)
|
29
|
+
mime-types (~> 1.16)
|
30
|
+
multi_json (~> 1.6)
|
31
|
+
rest-client (~> 1.6.1)
|
32
|
+
engineyard-serverside-adapter (2.2.0)
|
33
|
+
escape (~> 0.0.4)
|
34
|
+
multi_json (~> 1.6)
|
35
|
+
escape (0.0.4)
|
36
|
+
faraday (0.9.0)
|
37
|
+
multipart-post (>= 1.2, < 3)
|
38
|
+
highline (1.6.21)
|
39
|
+
http_router (0.11.1)
|
40
|
+
rack (>= 1.0.0)
|
41
|
+
url_mount (~> 0.2.1)
|
42
|
+
i18n (0.6.9)
|
43
|
+
ice_nine (0.11.0)
|
44
|
+
launchy (2.4.2)
|
45
|
+
addressable (~> 2.3)
|
46
|
+
lita (3.2.0)
|
47
|
+
bundler (>= 1.3)
|
48
|
+
faraday (>= 0.8.7)
|
49
|
+
http_router (>= 0.11.1)
|
50
|
+
i18n (>= 0.6.9)
|
51
|
+
ice_nine (>= 0.11.0)
|
52
|
+
multi_json (>= 1.7.7)
|
53
|
+
puma (>= 2.7.1)
|
54
|
+
rack (>= 1.5.2)
|
55
|
+
redis-namespace (>= 1.3.0)
|
56
|
+
thor (>= 0.18.1)
|
57
|
+
mime-types (1.25.1)
|
58
|
+
multi_json (1.10.0)
|
59
|
+
multipart-post (2.0.0)
|
60
|
+
net-ssh (2.9.1)
|
61
|
+
puma (2.8.2)
|
62
|
+
rack (>= 1.1, < 2.0)
|
63
|
+
rack (1.5.2)
|
64
|
+
rake (10.3.2)
|
65
|
+
redis (3.0.7)
|
66
|
+
redis-namespace (1.4.1)
|
67
|
+
redis (~> 3.0.4)
|
68
|
+
rest-client (1.6.7)
|
69
|
+
mime-types (>= 1.16)
|
70
|
+
rspec (3.0.0.beta2)
|
71
|
+
rspec-core (= 3.0.0.beta2)
|
72
|
+
rspec-expectations (= 3.0.0.beta2)
|
73
|
+
rspec-mocks (= 3.0.0.beta2)
|
74
|
+
rspec-core (3.0.0.beta2)
|
75
|
+
rspec-support (= 3.0.0.beta2)
|
76
|
+
rspec-expectations (3.0.0.beta2)
|
77
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
78
|
+
rspec-support (= 3.0.0.beta2)
|
79
|
+
rspec-mocks (3.0.0.beta2)
|
80
|
+
rspec-support (= 3.0.0.beta2)
|
81
|
+
rspec-support (3.0.0.beta2)
|
82
|
+
simplecov (0.8.2)
|
83
|
+
docile (~> 1.1.0)
|
84
|
+
multi_json
|
85
|
+
simplecov-html (~> 0.8.0)
|
86
|
+
simplecov-html (0.8.0)
|
87
|
+
term-ansicolor (1.3.0)
|
88
|
+
tins (~> 1.0)
|
89
|
+
thor (0.19.1)
|
90
|
+
tins (1.3.0)
|
91
|
+
url_mount (0.2.1)
|
92
|
+
rack
|
93
|
+
|
94
|
+
PLATFORMS
|
95
|
+
ruby
|
96
|
+
|
97
|
+
DEPENDENCIES
|
98
|
+
bundler
|
99
|
+
coveralls
|
100
|
+
lita-ey-deploy!
|
101
|
+
rake
|
102
|
+
rspec (>= 3.0.0.beta1)
|
103
|
+
simplecov
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2014 Carlos Paramio
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# lita-ey-deploy
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/carlosparamio/lita-ey-deploy.png?branch=master)](https://travis-ci.org/carlosparamio/lita-ey-deploy)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/carlosparamio/lita-ey-deploy.png)](https://codeclimate.com/github/carlosparamio/lita-ey-deploy)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/carlosparamio/lita-ey-deploy/badge.png)](https://coveralls.io/r/carlosparamio/lita-ey-deploy)
|
6
|
+
|
7
|
+
**lita-ey-deploy** is a handler for [Lita](http://lita.io/) that allows to manage deployments on EngineYard.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add lita-ey-deploy to your Lita instance's Gemfile:
|
12
|
+
|
13
|
+
``` ruby
|
14
|
+
gem "lita-ey-deploy"
|
15
|
+
```
|
16
|
+
|
17
|
+
Add required configuration to lita_config.rb file:
|
18
|
+
|
19
|
+
``` ruby
|
20
|
+
config.handlers.ey.api_token = "YOUR_EY_API_TOKEN"
|
21
|
+
config.handlers.ey.apps = {
|
22
|
+
"my_app_name_for_lita" => {
|
23
|
+
"name" => "my_app_name_at_ey",
|
24
|
+
"envs" => {
|
25
|
+
"test" => {
|
26
|
+
name: "testing"
|
27
|
+
auth_group: "devs"
|
28
|
+
default_branch: "develop"
|
29
|
+
},
|
30
|
+
"stage" => {
|
31
|
+
name: "staging"
|
32
|
+
auth_group: "testers"
|
33
|
+
default_branch: "stage"
|
34
|
+
},
|
35
|
+
"production" => {
|
36
|
+
name: "production"
|
37
|
+
auth_group: "devops"
|
38
|
+
default_branch: "master"
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
```
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
[MIT](http://opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
require "lita"
|
2
|
+
|
3
|
+
module Lita
|
4
|
+
module Handlers
|
5
|
+
class EyDeploy < Handler
|
6
|
+
|
7
|
+
route(/deploy help/i, :help, command: true, help: {
|
8
|
+
"deploy help" => "Display list of apps and envs available, and groups authorized to deploy on them"
|
9
|
+
})
|
10
|
+
|
11
|
+
route(/deploy (\w*) (\w*)( [\w\/\.\-\_]*)?/i, :deploy, command: true, help: {
|
12
|
+
"deploy [app] [env] <branch_name>" => "Deploy specified branch (or default) to env [test, staging, production]"
|
13
|
+
})
|
14
|
+
|
15
|
+
def self.default_config(config)
|
16
|
+
config.api_token = nil
|
17
|
+
config.apps = {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.namespace
|
21
|
+
"ey"
|
22
|
+
end
|
23
|
+
|
24
|
+
def help(response)
|
25
|
+
result = ""
|
26
|
+
config.apps.each do |app_name, app_data|
|
27
|
+
result += "App Name: #{app_name}\n"
|
28
|
+
result += " Environments:\n"
|
29
|
+
app_data["envs"].each do |env_name, env_data|
|
30
|
+
result += " * #{env_name}\n"
|
31
|
+
result += " Default branch: #{env_data["default_branch"]}\n"
|
32
|
+
result += " Authorized users group: #{env_data["auth_group"]}\n"
|
33
|
+
end
|
34
|
+
result += "\n"
|
35
|
+
end
|
36
|
+
response.reply result
|
37
|
+
end
|
38
|
+
|
39
|
+
def deploy(response)
|
40
|
+
app = response.matches[0][0].strip
|
41
|
+
env = response.matches[0][1].strip
|
42
|
+
|
43
|
+
response.reply "Deploy what to where?" and return unless valid_app?(app) && valid_env?(app, env)
|
44
|
+
|
45
|
+
branch = (response.matches[0][2] || default_branch_for(app, env)).strip
|
46
|
+
|
47
|
+
if can_deploy?(response.user, app, env)
|
48
|
+
response.reply "Deploying #{app} branch '#{branch}' to #{env}"
|
49
|
+
|
50
|
+
cmd = ey_deploy_cmd(app, env, branch)
|
51
|
+
response.reply cmd
|
52
|
+
deploy_result = `#{cmd}`
|
53
|
+
|
54
|
+
feedback_msg = deploy_result.include?(ey_failure_msg) ? failed_msg : success_msg
|
55
|
+
response.reply feedback_msg
|
56
|
+
else
|
57
|
+
response.reply "Sorry, you don't have access; you must me at #{required_group_to_deploy(app, env)} group."
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def valid_app?(app)
|
62
|
+
config.apps.keys.include?(app)
|
63
|
+
end
|
64
|
+
|
65
|
+
def valid_env?(app, env)
|
66
|
+
config.apps[app]["envs"].keys.include?(env)
|
67
|
+
end
|
68
|
+
|
69
|
+
def can_deploy?(user, app, env)
|
70
|
+
group = required_group_to_deploy(app, env)
|
71
|
+
return true unless group
|
72
|
+
Lita::Authorization.user_in_group? user, required_group_to_deploy(app, env)
|
73
|
+
end
|
74
|
+
|
75
|
+
def required_group_to_deploy(app, env)
|
76
|
+
config.apps[app]["envs"][env]["auth_group"]
|
77
|
+
end
|
78
|
+
|
79
|
+
def ey_deploy_cmd(app, env, branch)
|
80
|
+
"bundle exec ey deploy --app='#{ey_app(app)}' --environment='#{ey_env(app, env)}' --ref='refs/heads/#{branch}' --migrate='rake db:migrate' --api-token=#{config.api_token}"
|
81
|
+
end
|
82
|
+
|
83
|
+
def ey_failure_msg
|
84
|
+
"Failed deployment recorded on Engine Yard Cloud"
|
85
|
+
end
|
86
|
+
|
87
|
+
def success_msg
|
88
|
+
"Deployment done. Restarting!"
|
89
|
+
end
|
90
|
+
|
91
|
+
def failed_msg
|
92
|
+
"Deployment failed! Shame on you!"
|
93
|
+
end
|
94
|
+
|
95
|
+
def default_branch_for(app, env)
|
96
|
+
config.apps[app]["envs"][env]["default_branch"] || "master"
|
97
|
+
end
|
98
|
+
|
99
|
+
def ey_app(app)
|
100
|
+
config.apps[app]["name"]
|
101
|
+
end
|
102
|
+
|
103
|
+
def ey_env(app, env)
|
104
|
+
config.apps[app]["envs"][env]["name"]
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
Lita.register_handler(EyDeploy)
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "lita/handlers/ey_deploy"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-ey-deploy"
|
3
|
+
spec.version = "0.0.1"
|
4
|
+
spec.authors = ["Carlos Paramio"]
|
5
|
+
spec.email = ["cparamio@avallain.com"]
|
6
|
+
spec.description = %q{A Lita handler for EngineYard deployments.}
|
7
|
+
spec.summary = %q{A Lita handler for EngineYard deployments.}
|
8
|
+
spec.homepage = "https://github.com/carlosparamio/lita-ey-deploy"
|
9
|
+
spec.metadata = { "lita_plugin_type" => "handler" }
|
10
|
+
|
11
|
+
spec.files = `git ls-files`.split($/)
|
12
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
spec.add_runtime_dependency "lita", ">= 3.2.0"
|
17
|
+
|
18
|
+
spec.add_dependency "engineyard"
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler"
|
21
|
+
spec.add_development_dependency "coveralls"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", ">= 3.0.0.beta1"
|
24
|
+
spec.add_development_dependency "simplecov"
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-ey-deploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Carlos Paramio
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lita
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: engineyard
|
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: bundler
|
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: coveralls
|
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
|
+
- !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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 3.0.0.beta1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.0.0.beta1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: A Lita handler for EngineYard deployments.
|
112
|
+
email:
|
113
|
+
- cparamio@avallain.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- .rspec
|
120
|
+
- .travis.yml
|
121
|
+
- Gemfile
|
122
|
+
- Gemfile.lock
|
123
|
+
- LICENSE
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- lib/lita-ey-deploy.rb
|
127
|
+
- lib/lita/handlers/ey_deploy.rb
|
128
|
+
- lita-ey-deploy.gemspec
|
129
|
+
- spec/lita/handlers/ey_deploy_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
homepage: https://github.com/carlosparamio/lita-ey-deploy
|
132
|
+
licenses: []
|
133
|
+
metadata:
|
134
|
+
lita_plugin_type: handler
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.1.11
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: A Lita handler for EngineYard deployments.
|
155
|
+
test_files:
|
156
|
+
- spec/lita/handlers/ey_deploy_spec.rb
|
157
|
+
- spec/spec_helper.rb
|