ruboty-capistrano 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3c13f411365bbec3894c44ed61833129b43c65b
4
- data.tar.gz: 6432feb81209c5a7d27080d3fddae5977703bf9e
3
+ metadata.gz: 2d499dd93f9c06c725aee77f0e1f6ffe92535d0c
4
+ data.tar.gz: 6921665950ce222fd64d95df1ec32b3ac4abda44
5
5
  SHA512:
6
- metadata.gz: ee76be8385931163d75329c964ed8e32d1b93badab0bbd3236c5a2c9e284cd370c29671e3e735de3a28a6b46ad94770b7469cb867bacb6967d7c1775b1d001cf
7
- data.tar.gz: 4df1ddbebb5ebce663d23f92373a8c9fe127557a0c743857b29406368d9b132f934ed9c9ad7769d3dce022536649c58465f02c954c14da7cab10c3cf00a2ee9b
6
+ metadata.gz: f72432f08122159464ea4b10e775fe37e3dfc1073d78c35c8e3bf6fa7b267bbbdf2d0fdd80e2da454e34eea93c80ac874ee7739509723f5d3e101506ff71b7e8
7
+ data.tar.gz: ca74161862c3f33903a55ac2c356832bd645ff5dbfc0b3e7b3b7d536aeb275dd35f0119da706932fabd81a5f2df27ae9b93ff4476fbc407d3280eda3a19aa5c2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruboty-capistrano (0.1.0)
4
+ ruboty-capistrano (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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,5 +1,5 @@
1
1
  module Ruboty
2
2
  module Capistrano
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
- require "ruboty/capistrano/actions/deploy"
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.0
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-13 00:00:00.000000000 Z
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