ghdeploy 0.1.1 → 0.1.2

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: fe754e2aaec747cb2db9b4b3606ad615ec5e48fb
4
- data.tar.gz: 16b28a9f9601526376bf49defab8bbb3c20fe5d5
3
+ metadata.gz: 89fa641317633d7b702f440e6a34c22791c0d9ca
4
+ data.tar.gz: 9c353430d067dd6209c0c765bd2572e639e9a897
5
5
  SHA512:
6
- metadata.gz: 9ea0eecfcc02ddafd2639cdba1e0ce6a695b52543c37c6d174ba10531f32dcf124b3838ff28e49b316b214d7ceff7f59af481c5ed2c1bec0214952852e5b11b8
7
- data.tar.gz: 81f3aced632106c35422bde047f2f66e995c3d1da8f4c768c312663ab937305449c30bfbda0534ae4951a0ef482491774206c9791c1d6a95fb1edf5cbf2c1c46
6
+ metadata.gz: c95eac03ac885185bb5f074fe5c4a7ce9158a2d4126f2118db38e8fcbbe3239518e294b0e9168c53768f4c18f482e2880d288f4c81c5b1633f8e5f96e5ae5188
7
+ data.tar.gz: 9f32a17aa0a3969e662f00e371d542a5a54e340d45edcd0c1b003116e928843e779617900bac6cbb100f06585780640a4fb2fdd80a2922b623fcfd747c34879e
data/Gemfile.lock CHANGED
@@ -1,13 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ghdeploy (0.1.0)
5
- thor
4
+ ghdeploy (0.1.1)
5
+ git (~> 1.5)
6
+ octokit (~> 4.0)
7
+ thor (~> 0.20)
6
8
 
7
9
  GEM
8
10
  remote: https://rubygems.org/
9
11
  specs:
12
+ addressable (2.5.2)
13
+ public_suffix (>= 2.0.2, < 4.0)
10
14
  diff-lcs (1.3)
15
+ faraday (0.15.2)
16
+ multipart-post (>= 1.2, < 3)
17
+ git (1.5.0)
18
+ multipart-post (2.0.0)
19
+ octokit (4.9.0)
20
+ sawyer (~> 0.8.0, >= 0.5.3)
21
+ public_suffix (3.0.2)
11
22
  rake (10.5.0)
12
23
  rspec (3.7.0)
13
24
  rspec-core (~> 3.7.0)
@@ -22,6 +33,9 @@ GEM
22
33
  diff-lcs (>= 1.2.0, < 2.0)
23
34
  rspec-support (~> 3.7.0)
24
35
  rspec-support (3.7.1)
36
+ sawyer (0.8.1)
37
+ addressable (>= 2.3.5, < 2.6)
38
+ faraday (~> 0.8, < 1.0)
25
39
  thor (0.20.0)
26
40
 
27
41
  PLATFORMS
data/ghdeploy.gemspec CHANGED
@@ -21,7 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_runtime_dependency 'thor'
24
+ spec.add_runtime_dependency 'thor', '~> 0.20'
25
+ spec.add_runtime_dependency 'git', '~> 1.5'
26
+ spec.add_runtime_dependency 'octokit', '~> 4.0'
25
27
 
26
28
  spec.add_development_dependency 'bundler', '~> 1.16'
27
29
  spec.add_development_dependency 'rake', '~> 10.0'
data/lib/ghdeploy.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require "ghdeploy/version"
2
2
 
3
3
  module Ghdeploy
4
- # Your code goes here...
5
4
  end
data/lib/ghdeploy/cli.rb CHANGED
@@ -1,12 +1,24 @@
1
1
  require 'thor'
2
2
  require 'ghdeploy'
3
+ require 'octokit'
3
4
 
4
5
  module Ghdeploy
5
6
  class CLI < Thor
6
7
 
8
+ option :description
9
+ option :remote
10
+
7
11
  desc 'deploy', 'Creates a GitHub deployment.'
8
- def deploy
9
- puts 'test deploy'
12
+ def deploy(environment, ref)
13
+ remote_name = options[:remote] || 'origin'
14
+
15
+ facts = RepoFactFinder.new(remote_name)
16
+ Octokit.configure { |c| c.api_endpoint = "#{facts.host}/api/v3/" }
17
+ client = Octokit::Client.new(access_token: ENV.fetch('GHDEPLOY_TOKEN'))
18
+ deployment = client.create_deployment(facts.repo, ref, environment: environment)
19
+ puts "Deployment created!" if deployment.url
10
20
  end
21
+
22
+ default_task :deploy
11
23
  end
12
24
  end
@@ -0,0 +1,24 @@
1
+ require 'git'
2
+
3
+ # Figures out an API host to use based on the remote for the Git repository
4
+ class RepoFactFinder
5
+ URL_PATTERN = /^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?/
6
+
7
+ def initialize(remote_name)
8
+ @remote_name = remote_name
9
+ end
10
+
11
+ attr_reader :remote_name
12
+
13
+ def host
14
+ return @host if @host
15
+ url = Git.open('./').remotes.find { |r| r.name == remote_name }.url
16
+ if url.start_with?('http')
17
+ matches = URL_PATTERN.match(url)
18
+ @host = "#{matches[2]}://api.#{matches[3]}"
19
+ else
20
+ host = url.split('@').last.split(':').first
21
+ @host = "https://api.#{host}"
22
+ end
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module Ghdeploy
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,29 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghdeploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Joyce
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-11 00:00:00.000000000 Z
11
+ date: 2018-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.20'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.20'
27
+ - !ruby/object:Gem::Dependency
28
+ name: git
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '0'
33
+ version: '1.5'
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - ">="
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: octokit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
25
53
  - !ruby/object:Gem::Version
26
- version: '0'
54
+ version: '4.0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: bundler
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -89,6 +117,7 @@ files:
89
117
  - ghdeploy.gemspec
90
118
  - lib/ghdeploy.rb
91
119
  - lib/ghdeploy/cli.rb
120
+ - lib/ghdeploy/repo_fact_finder.rb
92
121
  - lib/ghdeploy/version.rb
93
122
  homepage: https://github.com/sonerdy/ghdeploy
94
123
  licenses: