orgupdatematrix 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +9 -3
- data/lib/orgupdatematrix.rb +15 -9
- data/lib/orgupdatematrix/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22b7ebb74cac46f5103f0139dc3dcc3dbb10ca14586c81cdb68319cd47673cfe
|
4
|
+
data.tar.gz: 1d2e00daf8c7c7d0ebb74638b8c4ef938a3125cf14cf9d826580561a7ceb8f26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ba57407f4254f3551d94811d1530fd77c1a3d2788c6780812d45d433b39af9ef89f1ed5666b39291b29226805a08f58c1f6549a03778ce9ce9be8ba5ae4a1b0
|
7
|
+
data.tar.gz: a261e70bfc2324ce988173385e5fc45c469230839ab9797a3da79d3bd2f5635de54dc11f22707ea3f379bfb3e20cdd2f2f8018fde897956fed158f7db0fd72cf
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
orgupdatematrix (0.
|
4
|
+
orgupdatematrix (0.2.0)
|
5
5
|
octokit (~> 4)
|
6
6
|
octopoller
|
7
7
|
|
@@ -12,11 +12,11 @@ GEM
|
|
12
12
|
public_suffix (>= 2.0.2, < 4.0)
|
13
13
|
faraday (0.15.4)
|
14
14
|
multipart-post (>= 1.2, < 3)
|
15
|
-
multipart-post (2.1.
|
15
|
+
multipart-post (2.1.1)
|
16
16
|
octokit (4.14.0)
|
17
17
|
sawyer (~> 0.8.0, >= 0.5.3)
|
18
18
|
octopoller (0.1.0)
|
19
|
-
public_suffix (3.0
|
19
|
+
public_suffix (3.1.0)
|
20
20
|
rake (10.5.0)
|
21
21
|
sawyer (0.8.2)
|
22
22
|
addressable (>= 2.3.5)
|
data/README.md
CHANGED
@@ -32,6 +32,12 @@ Add an `:app_url` variable to each deploy env file such as `deploy/environments/
|
|
32
32
|
set :app_url, 'https://staging.my-application.com'
|
33
33
|
```
|
34
34
|
|
35
|
+
Add the `matrix` role to the servers you want to report from:
|
36
|
+
|
37
|
+
```
|
38
|
+
server 'staging.my-application.com', user: 'deploy', roles: %w{web matrix}
|
39
|
+
```
|
40
|
+
|
35
41
|
Auth: generate a GitHub [personal access token](https://github.com/settings/tokens) and supply it at deploy time:
|
36
42
|
|
37
43
|
```
|
@@ -47,12 +53,12 @@ Add the following task to your Capistrano config eg. `deploy/config.rb`:
|
|
47
53
|
'my_var1' => 'value1',
|
48
54
|
'my_var2' => 'value2'
|
49
55
|
}
|
50
|
-
on roles(:
|
56
|
+
on roles(:matrix) do
|
51
57
|
within repo_path do
|
52
58
|
info 'Updating deploy matrix!'
|
53
59
|
commit = capture(:git, 'rev-list', '-n', '1', fetch(:branch)).chomp
|
54
60
|
updater = OrgUpdateMatrix::Updater.new('GitHubUser/RepoName', 'file-path.yml', ENV['GITHUB_API_TOKEN'])
|
55
|
-
updater.update(fetch(:application), fetch(:stage), fetch(:branch), commit, fetch(:app_url), fetch(:repo_url))
|
61
|
+
updater.update(fetch(:application), fetch(:stage), fetch(:branch), commit, fetch(:app_url), fetch(:repo_url), fetch(:extra_env))
|
56
62
|
end
|
57
63
|
end
|
58
64
|
end
|
@@ -70,7 +76,7 @@ app_name:
|
|
70
76
|
commit: 6209dc2138df2ecb808559d8f1c5bc41bfd17d0d
|
71
77
|
updated: 2019-05-09 03:51:50 UTC
|
72
78
|
app_url: https://staging.my-application.com
|
73
|
-
github_url: https
|
79
|
+
github_url: https://github.com/MyUser/AppRepo.git
|
74
80
|
extras:
|
75
81
|
my_var1: value1
|
76
82
|
my_var2: value2
|
data/lib/orgupdatematrix.rb
CHANGED
@@ -20,10 +20,18 @@ module OrgUpdateMatrix
|
|
20
20
|
puts("#{' ' * indent}#{message}")
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
23
|
+
def sort_data(hash)
|
24
|
+
hash.sort.to_h.each { |app, stage| hash[app] = stage.sort.to_h }
|
25
|
+
end
|
26
|
+
|
27
|
+
def update_yaml(file, app, stage, state)
|
25
28
|
data = YAML::load(Base64.decode64(file.content))
|
29
|
+
data[app] ||= {}
|
30
|
+
data[app][stage] = state
|
31
|
+
sort_data(data)
|
32
|
+
end
|
26
33
|
|
34
|
+
def update(app, stage, branch, commit, app_url, repo_url, extras = nil)
|
27
35
|
app = app.to_s
|
28
36
|
stage = stage.to_s
|
29
37
|
state = {
|
@@ -31,26 +39,24 @@ module OrgUpdateMatrix
|
|
31
39
|
'commit' => commit,
|
32
40
|
'updated' => Time.now.utc.to_s,
|
33
41
|
'app_url' => app_url,
|
34
|
-
'github_url' => repo_url.gsub('git@', 'https://').gsub(
|
42
|
+
'github_url' => repo_url.gsub('git@', 'https://').gsub(/(\w):(\w)/, '\1/\2'),
|
35
43
|
}
|
36
|
-
|
37
|
-
data[app] ||= {}
|
38
|
-
data[app][stage] = state
|
39
|
-
data[app][stage]['extras'] = extras if extras
|
44
|
+
state['extras'] = extras if extras
|
40
45
|
|
41
46
|
log("app: #{app}", 9)
|
42
47
|
log("stage: #{stage}", 9)
|
43
48
|
state.each { |key, value| log("#{key}: #{value}", 9) }
|
49
|
+
message = "update deploy matrix: #{app}:#{stage}"
|
44
50
|
|
45
51
|
Octopoller.poll(wait: :exponentially, retries: 6) do
|
46
52
|
begin
|
47
|
-
|
53
|
+
file = get_file_contents
|
54
|
+
data = update_yaml(file, app, stage, state)
|
48
55
|
result = @client.update_contents(@repo, @file_path, message, file[:sha], data.to_yaml)
|
49
56
|
log('Update complete!') if result[:commit]
|
50
57
|
rescue StandardError => e
|
51
58
|
log("Error: #{e.message}")
|
52
59
|
log('Retrying with latest commit...')
|
53
|
-
file = get_file_contents
|
54
60
|
:re_poll
|
55
61
|
end
|
56
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orgupdatematrix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Luntzel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|