factor-connector-github 0.0.4 → 0.0.6
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 +4 -4
- data/lib/factor/connector/github_deployments.rb +124 -0
- data/lib/factor/connector/github_releases.rb +124 -0
- data/lib/factor/connector/github_statuses.rb +74 -0
- metadata +15 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 574ddfdd712172c90584967b94c72b7cb07bb5b5
|
4
|
+
data.tar.gz: aa6d240b65f79735dcb2fa53a9c187266eed7a71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c03851e4f00f2a3c8ba8e6a5ee59d1f80448059873205f7da7b27fe885264bdafc6cca82373146c8fc3d312e50c52a3bffeecb3d7d889e30b8e4e26cf7c39b4b
|
7
|
+
data.tar.gz: 3c3f93b4f246ff9e0b4f2592c75710e9972b3152d1558c1d9d05267180111e598521f4ddc0574f1ba02adef2777f4b8b954b9b997c2af3d0950bea510319410a
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'factor-connector-api'
|
2
|
+
require 'github_api'
|
3
|
+
|
4
|
+
Factor::Connector.service 'github_deployments' do
|
5
|
+
action 'list' do |params|
|
6
|
+
api_key = params['api_key']
|
7
|
+
username = params['username']
|
8
|
+
repo = params['repo']
|
9
|
+
|
10
|
+
fail 'API Key must be defined' unless api_key
|
11
|
+
|
12
|
+
info 'Connecting to Github'
|
13
|
+
begin
|
14
|
+
github = Github.new oauth_token: api_key
|
15
|
+
rescue
|
16
|
+
fail 'Unable to connect to Github'
|
17
|
+
end
|
18
|
+
|
19
|
+
info 'Getting all deployments'
|
20
|
+
begin
|
21
|
+
deployments = []
|
22
|
+
github_wrapper = github.repos.deployments.list username, repo
|
23
|
+
github_wrapper.body.each { |mash| deployments << mash.to_hash }
|
24
|
+
rescue
|
25
|
+
fail 'Unable to get the deployment'
|
26
|
+
end
|
27
|
+
|
28
|
+
action_callback deployments
|
29
|
+
end
|
30
|
+
|
31
|
+
action 'create' do |params|
|
32
|
+
api_key = params['api_key']
|
33
|
+
username = params['username']
|
34
|
+
repo = params['repo']
|
35
|
+
ref = params['ref']
|
36
|
+
|
37
|
+
fail 'API Key (api_key) is required' unless api_key
|
38
|
+
fail 'Username (username) is required' unless username
|
39
|
+
fail 'Repo (repo) is required' unless repo
|
40
|
+
fail 'Ref (ref) is required' unless ref
|
41
|
+
|
42
|
+
info 'Connecting to Github'
|
43
|
+
begin
|
44
|
+
github = Github.new oauth_token: api_key
|
45
|
+
rescue
|
46
|
+
fail 'Unable to connect to Github'
|
47
|
+
end
|
48
|
+
|
49
|
+
tag_options = %w(ref task auto_merge required_contexts payload environment description force)
|
50
|
+
|
51
|
+
deployment_params = {}
|
52
|
+
params.each do |key,value|
|
53
|
+
deployment_params[key.to_sym] = value if tag_options.include?(key)
|
54
|
+
end
|
55
|
+
|
56
|
+
begin
|
57
|
+
status = github.repos.deployments.create username, repo, deployment_params
|
58
|
+
rescue
|
59
|
+
fail 'Failed to create the deployment'
|
60
|
+
end
|
61
|
+
action_callback status.body.to_hash
|
62
|
+
end
|
63
|
+
|
64
|
+
action 'statuses' do |params|
|
65
|
+
api_key = params['api_key']
|
66
|
+
username = params['username']
|
67
|
+
repo = params['repo']
|
68
|
+
id = params['id']
|
69
|
+
|
70
|
+
fail 'API Key must be defined' unless api_key
|
71
|
+
fail 'Deployment ID (id) is required' unless id
|
72
|
+
|
73
|
+
info 'Connecting to Github'
|
74
|
+
begin
|
75
|
+
github = Github.new oauth_token: api_key
|
76
|
+
rescue
|
77
|
+
fail 'Unable to connect to Github'
|
78
|
+
end
|
79
|
+
|
80
|
+
info 'Getting all deployments'
|
81
|
+
begin
|
82
|
+
deployment_statuses = []
|
83
|
+
github_wrapper = github.repos.deployments.statuses username, repo, id
|
84
|
+
github_wrapper.body.each { |mash| deployment_statuses << mash.to_hash }
|
85
|
+
rescue
|
86
|
+
fail 'Unable to get the deployment'
|
87
|
+
end
|
88
|
+
|
89
|
+
action_callback deployment_statuses
|
90
|
+
end
|
91
|
+
|
92
|
+
action 'create_status' do |params|
|
93
|
+
api_key = params['api_key']
|
94
|
+
username = params['username']
|
95
|
+
repo = params['repo']
|
96
|
+
id = params['id']
|
97
|
+
|
98
|
+
fail 'API Key (api_key) is required' unless api_key
|
99
|
+
fail 'Username (username) is required' unless username
|
100
|
+
fail 'Repo (repo) is required' unless repo
|
101
|
+
fail 'Deployment ID (id) is required' unless id
|
102
|
+
|
103
|
+
info 'Connecting to Github'
|
104
|
+
begin
|
105
|
+
github = Github.new oauth_token: api_key
|
106
|
+
rescue
|
107
|
+
fail 'Unable to connect to Github'
|
108
|
+
end
|
109
|
+
|
110
|
+
tag_options = %w(state target_url description)
|
111
|
+
|
112
|
+
status_params = {}
|
113
|
+
params.each do |key,value|
|
114
|
+
status_params[key.to_sym] = value if tag_options.include?(key)
|
115
|
+
end
|
116
|
+
|
117
|
+
begin
|
118
|
+
status = github.repos.deployments.create_status username, repo, id, status_params
|
119
|
+
rescue
|
120
|
+
fail 'Failed to create the deployment status'
|
121
|
+
end
|
122
|
+
action_callback status.body.to_hash
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'factor-connector-api'
|
2
|
+
require 'github_api'
|
3
|
+
|
4
|
+
Factor::Connector.service 'github_releases' do
|
5
|
+
action 'list' do |params|
|
6
|
+
api_key = params['api_key']
|
7
|
+
username = params['username']
|
8
|
+
repo = params['repo']
|
9
|
+
|
10
|
+
fail 'API Key must be defined' unless api_key
|
11
|
+
|
12
|
+
info 'Connecting to Github'
|
13
|
+
begin
|
14
|
+
github = Github.new oauth_token: api_key
|
15
|
+
rescue
|
16
|
+
fail 'Unable to connect to Github'
|
17
|
+
end
|
18
|
+
|
19
|
+
info 'Getting all releaes'
|
20
|
+
begin
|
21
|
+
releases = []
|
22
|
+
github_wrapper = github.repos.releases.list username, repo
|
23
|
+
github_wrapper.body.each { |mash| releases << mash.to_hash }
|
24
|
+
rescue
|
25
|
+
fail 'Unable to get the releases'
|
26
|
+
end
|
27
|
+
|
28
|
+
action_callback releases
|
29
|
+
end
|
30
|
+
|
31
|
+
action 'get' do |params|
|
32
|
+
api_key = params['api_key']
|
33
|
+
username = params['username']
|
34
|
+
repo = params['repo']
|
35
|
+
id = params['id']
|
36
|
+
|
37
|
+
fail 'API Key (api_key) is required' unless api_key
|
38
|
+
fail 'ID (id) is required' unless id
|
39
|
+
fail 'Username (username) is required' unless username
|
40
|
+
fail 'Repo (repo) is required' unless repo
|
41
|
+
|
42
|
+
info 'Connecting to Github'
|
43
|
+
begin
|
44
|
+
github = Github.new oauth_token: api_key
|
45
|
+
rescue
|
46
|
+
fail 'Unable to connect to Github'
|
47
|
+
end
|
48
|
+
|
49
|
+
info 'Getting all releaes'
|
50
|
+
begin
|
51
|
+
releases = []
|
52
|
+
github_wrapper = github.repos.releases.get username, repo, id
|
53
|
+
release = github_wrapper.body.to_hash
|
54
|
+
rescue
|
55
|
+
fail 'Unable to get the releases'
|
56
|
+
end
|
57
|
+
|
58
|
+
action_callback release
|
59
|
+
end
|
60
|
+
|
61
|
+
action 'create' do |params|
|
62
|
+
api_key = params['api_key']
|
63
|
+
username = params['username']
|
64
|
+
repo = params['repo']
|
65
|
+
tag_name = params['tag_name']
|
66
|
+
|
67
|
+
fail 'API Key (api_key) is required' unless api_key
|
68
|
+
fail 'Username (username) is required' unless username
|
69
|
+
fail 'Repo (repo) is required' unless repo
|
70
|
+
fail 'Tag Name (tag_name) is required' unless tag_name
|
71
|
+
|
72
|
+
info 'Connecting to Github'
|
73
|
+
begin
|
74
|
+
github = Github.new oauth_token: api_key
|
75
|
+
rescue
|
76
|
+
fail 'Unable to connect to Github'
|
77
|
+
end
|
78
|
+
|
79
|
+
tag_options = %w(target_commitish body name draft prerelease)
|
80
|
+
|
81
|
+
tag_params = {}
|
82
|
+
params.each do |key,value|
|
83
|
+
tag_params[key.to_sym] = value if tag_options.include?(key)
|
84
|
+
end
|
85
|
+
|
86
|
+
begin
|
87
|
+
release = github.repos.releases.create username, repo, tag_name, tag_params
|
88
|
+
rescue
|
89
|
+
fail 'Failed to tag the release'
|
90
|
+
end
|
91
|
+
|
92
|
+
action_callback release.body.to_hash
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
action 'delete' do |params|
|
97
|
+
api_key = params['api_key']
|
98
|
+
username = params['username']
|
99
|
+
repo = params['repo']
|
100
|
+
id = params['id']
|
101
|
+
|
102
|
+
fail 'API Key (api_key) is required' unless api_key
|
103
|
+
fail 'ID (id) is required' unless id
|
104
|
+
fail 'Username (username) is required' unless username
|
105
|
+
fail 'Repo (repo) is required' unless repo
|
106
|
+
|
107
|
+
info 'Connecting to Github'
|
108
|
+
begin
|
109
|
+
github = Github.new oauth_token: api_key
|
110
|
+
rescue
|
111
|
+
fail 'Unable to connect to Github'
|
112
|
+
end
|
113
|
+
|
114
|
+
info 'Getting all releaes'
|
115
|
+
begin
|
116
|
+
release = github.repos.releases.delete username, repo, id
|
117
|
+
rescue
|
118
|
+
fail 'Unable to get the releases'
|
119
|
+
end
|
120
|
+
|
121
|
+
action_callback
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'factor-connector-api'
|
2
|
+
require 'github_api'
|
3
|
+
|
4
|
+
Factor::Connector.service 'github_statuses' do
|
5
|
+
action 'list' do |params|
|
6
|
+
api_key = params['api_key']
|
7
|
+
username = params['username']
|
8
|
+
repo = params['repo']
|
9
|
+
ref = params['ref']
|
10
|
+
|
11
|
+
fail 'API Key must be defined' unless api_key
|
12
|
+
fail 'Ref (ref) must be defined' unless ref
|
13
|
+
|
14
|
+
info 'Connecting to Github'
|
15
|
+
begin
|
16
|
+
github = Github.new oauth_token: api_key
|
17
|
+
rescue
|
18
|
+
fail 'Unable to connect to Github'
|
19
|
+
end
|
20
|
+
|
21
|
+
info 'Getting all statuses'
|
22
|
+
begin
|
23
|
+
statuses = []
|
24
|
+
github_wrapper = github.repos.statuses.list username, repo, ref
|
25
|
+
github_wrapper.body.each { |mash| statuses << mash.to_hash }
|
26
|
+
rescue
|
27
|
+
fail 'Unable to get the statuses'
|
28
|
+
end
|
29
|
+
|
30
|
+
action_callback statuses
|
31
|
+
end
|
32
|
+
|
33
|
+
action 'create' do |params|
|
34
|
+
api_key = params['api_key']
|
35
|
+
username = params['username']
|
36
|
+
repo = params['repo']
|
37
|
+
sha = params['sha']
|
38
|
+
state = params['state']
|
39
|
+
description = params['description']
|
40
|
+
target_url = params['target_url']
|
41
|
+
context = params['context'] || 'default'
|
42
|
+
|
43
|
+
fail 'API Key (api_key) is required' unless api_key
|
44
|
+
fail 'Username (username) is required' unless username
|
45
|
+
fail 'Repo (repo) is required' unless repo
|
46
|
+
fail 'SHA (sha) is required' unless sha
|
47
|
+
fail 'State (state) is required' unless state
|
48
|
+
|
49
|
+
allowed_states = %w{pending success error failure}
|
50
|
+
|
51
|
+
fail "State (state) can only be #{allowed_states.join(',')}" unless allowed_states.include?(state)
|
52
|
+
|
53
|
+
info 'Connecting to Github'
|
54
|
+
begin
|
55
|
+
github = Github.new oauth_token: api_key
|
56
|
+
rescue
|
57
|
+
fail 'Unable to connect to Github'
|
58
|
+
end
|
59
|
+
|
60
|
+
tag_options = %w(state target_url description context)
|
61
|
+
|
62
|
+
status_params = {}
|
63
|
+
params.each do |key,value|
|
64
|
+
status_params[key.to_sym] = value if tag_options.include?(key)
|
65
|
+
end
|
66
|
+
|
67
|
+
begin
|
68
|
+
status = github.repos.statuses.create username, repo, sha, status_params
|
69
|
+
rescue
|
70
|
+
fail 'Failed to update the status'
|
71
|
+
end
|
72
|
+
action_callback status.body.to_hash
|
73
|
+
end
|
74
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factor-connector-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciej Skierkowski
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-01-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: github_api
|
@@ -17,42 +17,42 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.
|
20
|
+
version: 0.12.2
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.
|
27
|
+
version: 0.12.2
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: factor-connector-api
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.0.
|
34
|
+
version: 0.0.14
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0.0.
|
41
|
+
version: 0.0.14
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: codeclimate-test-reporter
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 0.4.
|
48
|
+
version: 0.4.5
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.4.
|
55
|
+
version: 0.4.5
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rspec
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,14 +73,14 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 10.
|
76
|
+
version: 10.4.2
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 10.
|
83
|
+
version: 10.4.2
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: wrong
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,14 +101,14 @@ dependencies:
|
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: 0.
|
104
|
+
version: 0.28.0
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: 0.
|
111
|
+
version: 0.28.0
|
112
112
|
description:
|
113
113
|
email:
|
114
114
|
- maciej@factor.io
|
@@ -117,8 +117,11 @@ executables: []
|
|
117
117
|
extensions: []
|
118
118
|
extra_rdoc_files: []
|
119
119
|
files:
|
120
|
+
- lib/factor/connector/github_deployments.rb
|
120
121
|
- lib/factor/connector/github_issue.rb
|
122
|
+
- lib/factor/connector/github_releases.rb
|
121
123
|
- lib/factor/connector/github_repo.rb
|
124
|
+
- lib/factor/connector/github_statuses.rb
|
122
125
|
homepage: https://factor.io
|
123
126
|
licenses: []
|
124
127
|
metadata: {}
|