Class: OpsDeploy::CLI::GitHub

Inherits:
Object
  • Object
show all
Defined in:
lib/ops_deploy/cli/github.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, deployment_info) ⇒ GitHub

Returns a new instance of GitHub.



4
5
6
7
# File 'lib/ops_deploy/cli/github.rb', line 4

def initialize(token, deployment_info)
  self.token = token
  self.deployment_info = deployment_info
end

Instance Attribute Details

#deployment_infoObject

Returns the value of attribute deployment_info.



2
3
4
# File 'lib/ops_deploy/cli/github.rb', line 2

def deployment_info
  @deployment_info
end

Instance Method Details

#create_deployment_status(state) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ops_deploy/cli/github.rb', line 9

def create_deployment_status(state)
  return unless valid?
  
  owner, repo = deployment_info[:owner], deployment_info[:repo]
  deployment_id = deployment_info[:deployment_id]
  url = "https://api.github.com/repos/#{owner}/#{repo}/deployments/#{deployment_id}"

  client = Octokit::Client.new(access_token: token)
  client.create_deployment_status(url, state, deployment_info[:options])
  
  self.deployment_info = nil
end

#valid?Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/ops_deploy/cli/github.rb', line 22

def valid?
  token && deployment_info &&
  deployment_info[:owner] && deployment_info[:repo] && deployment_info[:deployment_id]
end