module Octokit::Client::Environments

Methods for the Environments API

@see docs.github.com/en/rest/deployments/environments

Public Instance Methods

create_or_update_environment(repo, environment_name, options = {}) click to toggle source

Create or update an environment with protection rules, such as required reviewers

@param repo [Integer, String, Repository, Hash] A GitHub repository @param environment_name [String] The name of the environment @option options [Integer] :wait_timer The amount of time to delay a job after the job is initially triggered. The time (in minutes) must be an integer between 0 and 43,200 (30 days). @option options [Array] :reviewers The people or teams that may review jobs that reference the environment. You can list up to six users or teams as reviewers. @option options [Object] :deployment_branch_policy The type of deployment branch policy for this environment. To allow all branches to deploy, set to null. @return [Sawyer::Resource] An environment @see docs.github.com/en/rest/deployments/environments#create-or-update-an-environment

# File lib/octokit/client/environments.rb, line 43
def create_or_update_environment(repo, environment_name, options = {})
  put("#{Repository.path repo}/environments/#{environment_name}", options)
end
delete_environment(repo, environment_name, options = {}) click to toggle source

Delete an Environment

@param repo [Integer, String, Repository, Hash] A GitHub repository @param environment_name [String] The name of the environment @return [No Content] @see docs.github.com/en/rest/deployments/environments#delete-an-environment

# File lib/octokit/client/environments.rb, line 53
def delete_environment(repo, environment_name, options = {})
  delete("#{Repository.path repo}/environments/#{environment_name}", options)
end
environment(repo, environment_name, options = {}) click to toggle source

Fetch a single environment for a repository

@param repo [Integer, String, Repository, Hash] A GitHub repository @param environment_name [String] The name of the environment @return <Sawyer::Resource> A single environment @see docs.github.com/en/rest/deployments/environments#get-an-environment

# File lib/octokit/client/environments.rb, line 15
def environment(repo, environment_name, options = {})
  get("#{Repository.path repo}/environments/#{environment_name}", options)
end
environments(repo, options = {}) click to toggle source

Lists the environments for a repository

@param repo [Integer, String, Repository, Hash] A GitHub repository @option options [Integer] :per_page The number of results per page (max 100). Default: 30 @option options [Integer] :page Page number of the results to fetch. Default: 1 @return [Sawyer::Resource] Total count of environments and list of environments @see docs.github.com/en/rest/deployments/environments#list-environments

# File lib/octokit/client/environments.rb, line 26
def environments(repo, options = {})
  paginate("#{Repository.path repo}/environments", options) do |data, last_response|
    data.environments.concat last_response.data.environments
    data.total_count += last_response.data.total_count
  end
end
Also aliased as: list_environments
list_environments(repo, options = {})
Alias for: environments