ruboty-capistrano 0.1.0 → 0.1.1
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 -0
- data/lib/ruboty/capistrano/actions/rollback.rb +39 -0
- data/lib/ruboty/capistrano/version.rb +1 -1
- data/lib/ruboty/handlers/capistrano.rb +7 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d499dd93f9c06c725aee77f0e1f6ffe92535d0c
|
4
|
+
data.tar.gz: 6921665950ce222fd64d95df1ec32b3ac4abda44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f72432f08122159464ea4b10e775fe37e3dfc1073d78c35c8e3bf6fa7b267bbbdf2d0fdd80e2da454e34eea93c80ac874ee7739509723f5d3e101506ff71b7e8
|
7
|
+
data.tar.gz: ca74161862c3f33903a55ac2c356832bd645ff5dbfc0b3e7b3b7d536aeb275dd35f0119da706932fabd81a5f2df27ae9b93ff4476fbc407d3280eda3a19aa5c2
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -23,6 +23,17 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
![usage](https://cloud.githubusercontent.com/assets/1563239/16789796/6aa5a088-48eb-11e6-9422-fc98904255a9.jpg)
|
25
25
|
|
26
|
+
### Deploy
|
27
|
+
|
28
|
+
```
|
29
|
+
@bot_name deploy environment branch_name
|
30
|
+
```
|
31
|
+
|
32
|
+
### Rollback
|
33
|
+
|
34
|
+
```
|
35
|
+
@bot_name rollback environment
|
36
|
+
```
|
26
37
|
|
27
38
|
## Env
|
28
39
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Capistrano
|
3
|
+
module Actions
|
4
|
+
class Rollback < Ruboty::Actions::Base
|
5
|
+
class RollbackError < StandardError; end
|
6
|
+
|
7
|
+
attr_reader :message, :path, :env, :role
|
8
|
+
|
9
|
+
def initialize(message)
|
10
|
+
@message = message
|
11
|
+
@env = Ruboty::Capistrano.config.env
|
12
|
+
@role = message.match_data[1]
|
13
|
+
@path = Ruboty::Capistrano.config.repository_path[@role]
|
14
|
+
end
|
15
|
+
|
16
|
+
def call
|
17
|
+
message.reply("#{@env}環境の#{@role}をrollbackします")
|
18
|
+
rollback
|
19
|
+
message.reply("#{@env}環境の#{@role}をrollback完了しました")
|
20
|
+
rescue => e
|
21
|
+
err_message = <<~TEXT
|
22
|
+
:cop:問題が発生しました:cop:
|
23
|
+
```
|
24
|
+
#{e.message}
|
25
|
+
```
|
26
|
+
TEXT
|
27
|
+
message.reply(err_message)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
def rollback
|
32
|
+
cmd = "cd #{path} && bundle && bundle exec cap #{@env} deploy:rollback"
|
33
|
+
out, err, status = Bundler.with_clean_env { Open3.capture3(cmd) }
|
34
|
+
raise RollbackError.new(err) unless err.empty?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require 'ruboty/capistrano/actions/deploy'
|
2
|
+
require 'ruboty/capistrano/actions/rollback'
|
2
3
|
|
3
4
|
module Ruboty
|
4
5
|
module Handlers
|
@@ -6,10 +7,15 @@ module Ruboty
|
|
6
7
|
env :DEPLOY_REPOSITORY_PATH, 'Deploy用の Repository Path を設定する'
|
7
8
|
|
8
9
|
on(/deploy\s+(.*)\s+(.*)/m, name: 'deploy', description: 'deployする')
|
10
|
+
on(/rollback\s+(.*)/m, name: 'rollback', description: 'rollbackする')
|
9
11
|
|
10
12
|
def deploy(message)
|
11
13
|
Ruboty::Capistrano::Actions::Deploy.new(message).call
|
12
14
|
end
|
15
|
+
|
16
|
+
def rollback(message)
|
17
|
+
Ruboty::Capistrano::Actions::Rollback.new(message).call
|
18
|
+
end
|
13
19
|
end
|
14
20
|
end
|
15
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-capistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Morioka Shuhei
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- bin/setup
|
85
85
|
- lib/ruboty/capistrano.rb
|
86
86
|
- lib/ruboty/capistrano/actions/deploy.rb
|
87
|
+
- lib/ruboty/capistrano/actions/rollback.rb
|
87
88
|
- lib/ruboty/capistrano/config.rb
|
88
89
|
- lib/ruboty/capistrano/version.rb
|
89
90
|
- lib/ruboty/handlers/capistrano.rb
|