Module: Octokit::Client::Deployments

Included in:
Octokit::Client
Defined in:
lib/octokit/client/deployments.rb

Overview

Methods for the Deployments API

Constant Summary collapse

DEPLOYMENTS_PREVIEW_MEDIA_TYPE =
"application/vnd.github.cannonball-preview+json".freeze

Instance Method Summary collapse

Instance Method Details

#create_deployment(repo, ref, options = {}) ⇒ Sawyer::Resource

Create a deployment for a ref

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • ref (String)

    The ref to deploy

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :payload (String)

    Meta info about the deployment

  • :force (String)

    Optional parameter to bypass any ahead/behind checks or commit status checks. Default: false

  • :auto_merge (String)

    Optional parameter to merge the default branch into the requested deployment branch if necessary. Default: false

  • :description (String)

    Optional short description.

Returns:

  • (Sawyer::Resource)

    A deployment

See Also:



32
33
34
35
36
# File 'lib/octokit/client/deployments.rb', line 32

def create_deployment(repo, ref, options = {})
  options = ensure_deployments_api_media_type(options)
  options[:ref] = ref
  post("repos/#{Repository.new(repo)}/deployments", options)
end

#create_deployment_status(deployment_url, state, options = {}) ⇒ Sawyer::Resource

Create a deployment status for a Deployment

Parameters:

  • deployment_url (String)

    A URL for a deployment resource

  • state (String)

    The state: pending, success, failure, error

Returns:

  • (Sawyer::Resource)

    A deployment status

See Also:



56
57
58
59
60
61
# File 'lib/octokit/client/deployments.rb', line 56

def create_deployment_status(deployment_url, state, options = {})
  options = ensure_deployments_api_media_type(options)
  deployment = get(deployment_url, :accept => options[:accept])
  options[:state] = state.to_s.downcase
  post(deployment.rels[:statuses].href, options)
end

#deployment_statuses(deployment_url, options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_deployment_statuses

List all statuses for a Deployment

Parameters:

  • deployment_url (String)

    A URL for a deployment resource

Returns:

  • (Array<Sawyer::Resource>)

    A list of deployment statuses

See Also:



43
44
45
46
47
# File 'lib/octokit/client/deployments.rb', line 43

def deployment_statuses(deployment_url, options = {})
  options = ensure_deployments_api_media_type(options)
  deployment = get(deployment_url, :accept => options[:accept])
  get(deployment.rels[:statuses].href, options)
end

#deployments(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_deployments

List all deployments for a repository

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

Returns:

  • (Array<Sawyer::Resource>)

    A list of deployments

See Also:



16
17
18
19
# File 'lib/octokit/client/deployments.rb', line 16

def deployments(repo, options = {})
  options = ensure_deployments_api_media_type(options)
  get("repos/#{Repository.new(repo)}/deployments", options)
end