lita-ey-deploy 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +11 -7
- data/lib/lita/handlers/ey_deploy.rb +89 -6
- data/lita-ey-deploy.gemspec +1 -1
- data/spec/lita/handlers/ey_deploy_spec.rb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47b06676ac6fad381f37a7ab3c596429748d74fd
|
4
|
+
data.tar.gz: 130b27bf17759ee504fe937897b5eea3fb8e434d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36745002e9bb3628118e7a783579d5e58df4e4b03db7c78b34c726c7ddd4acdf32fdd294e6fec73cc2245fd9f9d8fdf02f21654ee38599cb9257f16222f4a028
|
7
|
+
data.tar.gz: 7f0f35f21d5ee1f7ec79a109f54f3f173a4c9fa35451d924acbf980b75c01881b346e4d0c7ee50b83b6b672e743a91d5df2e240a509b82c27cb8880ed9b8673e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[![Code Climate](https://codeclimate.com/github/carlosparamio/lita-ey-deploy.png)](https://codeclimate.com/github/carlosparamio/lita-ey-deploy)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/carlosparamio/lita-ey-deploy/badge.png)](https://coveralls.io/r/carlosparamio/lita-ey-deploy)
|
6
6
|
|
7
|
-
**lita-ey-deploy** is a handler for [Lita](http://lita.io/) that allows to manage deployments on EngineYard.
|
7
|
+
**lita-ey-deploy** is a handler for [Lita](http://lita.io/) that allows to manage deployments, rollbacks and maintenance page management on EngineYard.
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -23,18 +23,18 @@ Add required configuration to lita_config.rb file:
|
|
23
23
|
"name" => "my_app_name_at_ey",
|
24
24
|
"envs" => {
|
25
25
|
"test" => {
|
26
|
-
name: "testing"
|
27
|
-
auth_group: "devs"
|
26
|
+
name: "testing",
|
27
|
+
auth_group: "devs",
|
28
28
|
default_branch: "develop"
|
29
29
|
},
|
30
30
|
"stage" => {
|
31
|
-
name: "staging"
|
32
|
-
auth_group: "testers"
|
31
|
+
name: "staging",
|
32
|
+
auth_group: "testers",
|
33
33
|
default_branch: "stage"
|
34
34
|
},
|
35
35
|
"production" => {
|
36
|
-
name: "production"
|
37
|
-
auth_group: "devops"
|
36
|
+
name: "production",
|
37
|
+
auth_group: "devops",
|
38
38
|
default_branch: "master"
|
39
39
|
}
|
40
40
|
}
|
@@ -42,6 +42,10 @@ Add required configuration to lita_config.rb file:
|
|
42
42
|
}
|
43
43
|
```
|
44
44
|
|
45
|
+
## See also
|
46
|
+
|
47
|
+
[lita-ey-info](http://github.com/carlosparamio/lita-ey-info)
|
48
|
+
|
45
49
|
## License
|
46
50
|
|
47
51
|
[MIT](http://opensource.org/licenses/MIT)
|
@@ -9,7 +9,19 @@ module Lita
|
|
9
9
|
})
|
10
10
|
|
11
11
|
route(/ey deploy (\w*) (\w*)( [\w\/\.\-\_]*)?/i, :deploy, command: true, help: {
|
12
|
-
"ey deploy [app] [env] <branch_name>" => "Deploy specified branch (or default) to
|
12
|
+
"ey deploy [app] [env] <branch_name>" => "Deploy specified branch (or default) to a particular app env"
|
13
|
+
})
|
14
|
+
|
15
|
+
route(/ey rollback (\w*) (\w*)/i, :rollback, command: true, help: {
|
16
|
+
"ey rollback [app] [env]" => "Rollback a particular app env to previous version"
|
17
|
+
})
|
18
|
+
|
19
|
+
route(/ey maintenance on (\w*) (\w*)/i, :enable_maintenance, command: true, help: {
|
20
|
+
"ey maintenance on [app] [env]" => "Place maintenance page at a particular app env"
|
21
|
+
})
|
22
|
+
|
23
|
+
route(/ey maintenance off (\w*) (\w*)/i, :disable_maintenance, command: true, help: {
|
24
|
+
"ey maintenance off [app] [env]" => "Disable maintenance page at a particular app env"
|
13
25
|
})
|
14
26
|
|
15
27
|
def self.default_config(config)
|
@@ -47,12 +59,71 @@ module Lita
|
|
47
59
|
if can_deploy?(response.user, app, env)
|
48
60
|
response.reply "Deploying #{app} branch '#{branch}' to #{env}"
|
49
61
|
|
50
|
-
|
62
|
+
cmd = ey_deploy_cmd(app, env, branch)
|
63
|
+
Lita.logger.info cmd
|
64
|
+
deploy_result = `#{cmd}`
|
51
65
|
|
52
66
|
feedback_msg = deploy_result.include?(ey_failure_msg) ? failed_msg : success_msg
|
53
67
|
response.reply feedback_msg
|
54
68
|
else
|
55
|
-
response.reply access_denied % { group_name:
|
69
|
+
response.reply access_denied % { group_name: required_group_to_access(app, env) }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def rollback(response)
|
74
|
+
app = response.matches[0][0].strip
|
75
|
+
env = response.matches[0][1].strip
|
76
|
+
|
77
|
+
response.reply "Rollback what?" and return unless valid_app?(app) && valid_env?(app, env)
|
78
|
+
|
79
|
+
if can_deploy?(response.user, app, env)
|
80
|
+
response.reply "Rolling back #{app} #{env} to previous version..."
|
81
|
+
|
82
|
+
cmd = ey_rollback_cmd(app, env)
|
83
|
+
Lita.logger.info cmd
|
84
|
+
result = `#{cmd}`
|
85
|
+
|
86
|
+
response.reply result
|
87
|
+
else
|
88
|
+
response.reply access_denied % { group_name: required_group_to_access(app, env) }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def enable_maintenance(response)
|
93
|
+
app = response.matches[0][0].strip
|
94
|
+
env = response.matches[0][1].strip
|
95
|
+
|
96
|
+
response.reply "Place maintenance page where?" and return unless valid_app?(app) && valid_env?(app, env)
|
97
|
+
|
98
|
+
if can_deploy?(response.user, app, env)
|
99
|
+
response.reply "Placing maintenance page at #{app} #{env}..."
|
100
|
+
|
101
|
+
cmd = ey_maintenance_on_cmd(app, env)
|
102
|
+
Lita.logger.info cmd
|
103
|
+
result = `#{cmd}`
|
104
|
+
|
105
|
+
response.reply result
|
106
|
+
else
|
107
|
+
response.reply access_denied % { group_name: required_group_to_access(app, env) }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def disable_maintenance(response)
|
112
|
+
app = response.matches[0][0].strip
|
113
|
+
env = response.matches[0][1].strip
|
114
|
+
|
115
|
+
response.reply "Disable maintenance page where?" and return unless valid_app?(app) && valid_env?(app, env)
|
116
|
+
|
117
|
+
if can_deploy?(response.user, app, env)
|
118
|
+
response.reply "Disabling maintenance page at #{app} #{env}..."
|
119
|
+
|
120
|
+
cmd = ey_maintenance_on_cmd(app, env)
|
121
|
+
Lita.logger.info cmd
|
122
|
+
result = `#{cmd}`
|
123
|
+
|
124
|
+
response.reply result
|
125
|
+
else
|
126
|
+
response.reply access_denied % { group_name: required_group_to_access(app, env) }
|
56
127
|
end
|
57
128
|
end
|
58
129
|
|
@@ -65,12 +136,12 @@ module Lita
|
|
65
136
|
end
|
66
137
|
|
67
138
|
def can_deploy?(user, app, env)
|
68
|
-
group =
|
139
|
+
group = required_group_to_access(app, env)
|
69
140
|
return true unless group
|
70
|
-
Lita::Authorization.user_in_group? user,
|
141
|
+
Lita::Authorization.user_in_group? user, required_group_to_access(app, env)
|
71
142
|
end
|
72
143
|
|
73
|
-
def
|
144
|
+
def required_group_to_access(app, env)
|
74
145
|
config.apps[app]["envs"][env]["auth_group"]
|
75
146
|
end
|
76
147
|
|
@@ -78,6 +149,18 @@ module Lita
|
|
78
149
|
"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}"
|
79
150
|
end
|
80
151
|
|
152
|
+
def ey_rollback_cmd(app, env)
|
153
|
+
"bundle exec ey rollback --app='#{ey_app(app)}' --environment='#{ey_env(app, env)}' --api-token=#{config.api_token}"
|
154
|
+
end
|
155
|
+
|
156
|
+
def ey_maintenance_on_cmd(app, env)
|
157
|
+
"bundle exec ey web disable --app='#{ey_app(app)}' --environment='#{ey_env(app, env)}' --api-token=#{config.api_token}"
|
158
|
+
end
|
159
|
+
|
160
|
+
def ey_maintenance_off_cmd(app, env)
|
161
|
+
"bundle exec ey web enable --app='#{ey_app(app)}' --environment='#{ey_env(app, env)}' --api-token=#{config.api_token}"
|
162
|
+
end
|
163
|
+
|
81
164
|
def ey_failure_msg
|
82
165
|
"Failed deployment recorded on Engine Yard Cloud"
|
83
166
|
end
|
data/lita-ey-deploy.gemspec
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Lita::Handlers::EyDeploy, lita_handler: true do
|
4
|
-
it { routes_command("ey deploy appname envname
|
4
|
+
it { routes_command("ey deploy appname envname").to(:deploy) }
|
5
5
|
it { routes_command("ey deploy appname envname release/1.0").to(:deploy) }
|
6
|
+
it { routes_command("ey rollback appname envname").to(:rollback) }
|
7
|
+
it { routes_command("ey maintenance on appname envname").to(:enable_maintenance) }
|
8
|
+
it { routes_command("ey maintenance off appname envname").to(:disable_maintenance) }
|
6
9
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-ey-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Paramio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|