Skip to main content
REST API はバージョン管理になりました。 詳細については、「API のバージョン管理について」を参照してください。

デプロイ ブランチ ポリシー用の REST API エンドポイント

REST API を使って、カスタム デプロイ ブランチ ポリシーを管理します。

デプロイ ブランチ ポリシーについて

REST API を使って、環境にデプロイするためにブランチが一致する必要があるカスタム名パターンを指定できます。 これらのエンドポイントを使用するには、環境の deployment_branch_policy.custom_branch_policies プロパティを true に設定する必要があります。 環境の deployment_branch_policy を更新する方法については、「Deployment Environments 用 REST API エンドポイント」を参照してください。

環境のデプロイを特定のブランチに制限する方法については、「デプロイに環境を使用する」を参照してください。

List deployment branch policies

Lists 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.

"List deployment branch policies" のきめ細かいアクセス トークン

このエンドポイントは、次のトークンの種類で動作します:

トークンには次のアクセス許可が設定されている必要があります:

  • actions:read

このエンドポイントは、パブリック リソースのみが要求される場合は、認証または前述メンションアクセス許可なしで使用できます。

"List deployment branch policies" のパラメーター

ヘッダー
名前, Type, 説明
accept string

Setting to application/vnd.github+json is recommended.

パス パラメーター
名前, Type, 説明
owner string 必須

The account owner of the repository. The name is not case sensitive.

repo string 必須

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string 必須

The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

クエリ パラメーター
名前, Type, 説明
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Default: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Default: 1

"List deployment branch policies" の HTTP 応答状態コード

状態コード説明
200

OK

"List deployment branch policies" のコード サンプル

要求の例

get/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies

Response

Status: 200
{ "total_count": 2, "branch_policies": [ { "id": 361471, "node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjE0NzE=", "name": "release/*" }, { "id": 361472, "node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjE0NzI=", "name": "main" } ] }

Create a deployment branch policy

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.

"Create a deployment branch policy" のきめ細かいアクセス トークン

このエンドポイントは、次のトークンの種類で動作します:

トークンには次のアクセス許可が設定されている必要があります:

  • administration:write

"Create a deployment branch policy" のパラメーター

ヘッダー
名前, Type, 説明
accept string

Setting to application/vnd.github+json is recommended.

パス パラメーター
名前, Type, 説明
owner string 必須

The account owner of the repository. The name is not case sensitive.

repo string 必須

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string 必須

The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

本文のパラメーター
名前, Type, 説明
name string 必須

The name pattern that branches or tags must match in order to deploy to the environment.

Wildcard characters will not match /. For example, to match branches that begin with release/ and contain an additional single slash, use release/*/*. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.

type string

Whether this rule targets a branch or tag

次のいずれかにできます: branch, tag

"Create a deployment branch policy" の HTTP 応答状態コード

状態コード説明
200

OK

303

Response if the same branch name pattern already exists

404

Not Found or deployment_branch_policy.custom_branch_policies property for the environment is set to false

"Create a deployment branch policy" のコード サンプル

要求の例

post/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies \ -d '{"name":"release/*"}'

Response

Status: 200
{ "id": 364662, "node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjQ2NjI=", "name": "release/*" }

Get a deployment branch policy

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.

"Get a deployment branch policy" のきめ細かいアクセス トークン

このエンドポイントは、次のトークンの種類で動作します:

トークンには次のアクセス許可が設定されている必要があります:

  • actions:read

このエンドポイントは、パブリック リソースのみが要求される場合は、認証または前述メンションアクセス許可なしで使用できます。

"Get a deployment branch policy" のパラメーター

ヘッダー
名前, Type, 説明
accept string

Setting to application/vnd.github+json is recommended.

パス パラメーター
名前, Type, 説明
owner string 必須

The account owner of the repository. The name is not case sensitive.

repo string 必須

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string 必須

The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

branch_policy_id integer 必須

The unique identifier of the branch policy.

"Get a deployment branch policy" の HTTP 応答状態コード

状態コード説明
200

OK

"Get a deployment branch policy" のコード サンプル

要求の例

get/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID

Response

Status: 200
{ "id": 364662, "node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjQ2NjI=", "name": "release/*" }

Update a deployment branch policy

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.

"Update a deployment branch policy" のきめ細かいアクセス トークン

このエンドポイントは、次のトークンの種類で動作します:

トークンには次のアクセス許可が設定されている必要があります:

  • administration:write

"Update a deployment branch policy" のパラメーター

ヘッダー
名前, Type, 説明
accept string

Setting to application/vnd.github+json is recommended.

パス パラメーター
名前, Type, 説明
owner string 必須

The account owner of the repository. The name is not case sensitive.

repo string 必須

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string 必須

The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

branch_policy_id integer 必須

The unique identifier of the branch policy.

本文のパラメーター
名前, Type, 説明
name string 必須

The name pattern that branches must match in order to deploy to the environment.

Wildcard characters will not match /. For example, to match branches that begin with release/ and contain an additional single slash, use release/*/*. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.

"Update a deployment branch policy" の HTTP 応答状態コード

状態コード説明
200

OK

"Update a deployment branch policy" のコード サンプル

要求の例

put/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID \ -d '{"name":"release/*"}'

Response

Status: 200
{ "id": 364662, "node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjQ2NjI=", "name": "release/*" }

Delete a deployment branch policy

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 a deployment branch policy" のきめ細かいアクセス トークン

このエンドポイントは、次のトークンの種類で動作します:

トークンには次のアクセス許可が設定されている必要があります:

  • administration:write

"Delete a deployment branch policy" のパラメーター

ヘッダー
名前, Type, 説明
accept string

Setting to application/vnd.github+json is recommended.

パス パラメーター
名前, Type, 説明
owner string 必須

The account owner of the repository. The name is not case sensitive.

repo string 必須

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string 必須

The name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

branch_policy_id integer 必須

The unique identifier of the branch policy.

"Delete a deployment branch policy" の HTTP 応答状態コード

状態コード説明
204

No Content

"Delete a deployment branch policy" のコード サンプル

要求の例

delete/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID

Response

Status: 204