mina-twist 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/lib/mina/twist/tasks.rb +47 -0
- data/lib/mina/twist/version.rb +6 -0
- data/lib/mina/twist.rb +7 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 34f2641ff25b582ebde5b55e9b02549e59ac8b6877c106d24434dd01bcfdb085
|
4
|
+
data.tar.gz: 8f398094163f6e635ae90c866113b8d60043ab8cb4f16474d28a4357bab6e0f9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e0c67c069fb50f5084d8b5464c51f7bb77bbb44b1ad0eef1d1b451d475f8c0c0f3250ff3efc1936c6752d662ecacb0f654c737afdd51c5e74852427322658f0e
|
7
|
+
data.tar.gz: 84c3eb84f5553fdd2830d3d77e505bf587b59c6770b6046936e10dfa0deac890334b77f4edfdf8d3f38353bf480a8ed1d34a1e22c91a765e967fd1299fe0779e
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'net/http'
|
3
|
+
require 'mina'
|
4
|
+
|
5
|
+
namespace :twist do
|
6
|
+
set :twist_url, -> { ENV['TWIST_URL'] }
|
7
|
+
set :author, -> { ENV['GIT_AUTHOR_NAME'] || `git config user.name`.chomp }
|
8
|
+
set :commit, -> { ENV['GIT_COMMIT'] || `git rev-parse #{fetch(:branch)} | cut -c 1-7`.strip }
|
9
|
+
set :environment, -> { ENV['to'] }
|
10
|
+
|
11
|
+
task :starting do
|
12
|
+
notification = "#{fetch(:author).call} is deploying branch #{branch_name} to #{fetch(:environment).call}"
|
13
|
+
post_twist_thread(notification)
|
14
|
+
set(:start_time, Time.now)
|
15
|
+
end
|
16
|
+
|
17
|
+
task :finished do
|
18
|
+
end_time = Time.now
|
19
|
+
start_time = fetch(:start_time)
|
20
|
+
elapsed = end_time.to_i - start_time.to_i
|
21
|
+
|
22
|
+
notification = "#{fetch(:author).call} successfully deployed branch #{branch_name} in #{elapsed} seconds."
|
23
|
+
post_twist_thread(notification)
|
24
|
+
end
|
25
|
+
|
26
|
+
def branch_name
|
27
|
+
"#{fetch(:branch)} (#{fetch(:commit).call})"
|
28
|
+
end
|
29
|
+
|
30
|
+
def post_twist_thread(message)
|
31
|
+
uri = URI.parse(fetch(:twist_url))
|
32
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
33
|
+
http.use_ssl = true
|
34
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
35
|
+
|
36
|
+
payload = {
|
37
|
+
content: message
|
38
|
+
}
|
39
|
+
headers = {'Content-Type': 'application/json'}
|
40
|
+
|
41
|
+
request = Net::HTTP::Post.new(uri.request_uri, headers)
|
42
|
+
request.body = payload.to_json
|
43
|
+
|
44
|
+
# Call Twist webhook
|
45
|
+
puts http.request(request)
|
46
|
+
end
|
47
|
+
end
|
data/lib/mina/twist.rb
ADDED
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mina-twist
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rodrigo Coutinho
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-06-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: pry
|
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: mina
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.3.8
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.3.8
|
69
|
+
description: Twist web hook from mina
|
70
|
+
email:
|
71
|
+
- rodrigo.coutinho15@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- lib/mina/twist.rb
|
77
|
+
- lib/mina/twist/tasks.rb
|
78
|
+
- lib/mina/twist/version.rb
|
79
|
+
homepage: https://github.com/digaoddc/mina-twist
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubygems_version: 3.0.3
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Twist web hook from mina
|
102
|
+
test_files: []
|