Skip to main content

branch_policies

Creates, updates, deletes, gets or lists a branch_policies resource.

Overview

Namebranch_policies
TypeResource
Idgithub.repos.branch_policies

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
idintegerThe unique identifier of the branch or tag policy.
namestringThe name pattern that branches or tags must match in order to deploy to the environment. (example: release/*)
node_idstring (example: MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjE0NzE=)
typestringWhether this rule targets a branch or tag. (branch, tag) (example: branch)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_deployment_branch_policyselectowner, repo, environment_name, branch_policy_idGets a deployment branch or tag policy for an environment.

Anyone with read access to the repository can use this endpoint.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private repository.
list_deployment_branch_policiesselectowner, repo, environment_nameper_page, pageLists the deployment branch policies for an environment.

Anyone with read access to the repository can use this endpoint.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private repository.
create_deployment_branch_policyinsertowner, repo, environment_name, nameCreates a deployment branch or tag policy for an environment.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.
update_deployment_branch_policyreplaceowner, repo, environment_name, branch_policy_id, nameUpdates a deployment branch or tag policy for an environment.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.
delete_deployment_branch_policydeleteowner, repo, environment_name, branch_policy_idDeletes a deployment branch or tag policy for an environment.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
branch_policy_idintegerThe unique identifier of the branch policy.
environment_namestringThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.
ownerstringThe account owner of the repository. The name is not case sensitive.
repostringThe name of the repository without the .git extension. The name is not case sensitive.
pageintegerThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pageintegerThe number of results per page (max 100). For more information, see "Using pagination in the REST API."

SELECT examples

Gets a deployment branch or tag policy for an environment.

Anyone with read access to the repository can use this endpoint.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with a private repository.

SELECT
id,
name,
node_id,
type
FROM github.repos.branch_policies
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND environment_name = '{{ environment_name }}' -- required
AND branch_policy_id = '{{ branch_policy_id }}' -- required
;

INSERT examples

Creates a deployment branch or tag policy for an environment.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

INSERT INTO github.repos.branch_policies (
name,
type,
owner,
repo,
environment_name
)
SELECT
'{{ name }}' /* required */,
'{{ type }}',
'{{ owner }}',
'{{ repo }}',
'{{ environment_name }}'
RETURNING
id,
name,
node_id,
type
;

REPLACE examples

Updates a deployment branch or tag policy for an environment.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

REPLACE github.repos.branch_policies
SET
name = '{{ name }}'
WHERE
owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND environment_name = '{{ environment_name }}' --required
AND branch_policy_id = '{{ branch_policy_id }}' --required
AND name = '{{ name }}' --required
RETURNING
id,
name,
node_id,
type;

DELETE examples

Deletes a deployment branch or tag policy for an environment.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

DELETE FROM github.repos.branch_policies
WHERE owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND environment_name = '{{ environment_name }}' --required
AND branch_policy_id = '{{ branch_policy_id }}' --required
;