Skip to main content
ドキュメントへの更新が頻繁に発行されており、このページの翻訳はまだ行われている場合があります。 最新の情報については、「英語のドキュメント」を参照してください。

このバージョンの GitHub Enterprise はこの日付をもって終了となりました: 2023-03-15. 重大なセキュリティの問題に対してであっても、パッチリリースは作成されません。 パフォーマンスの向上、セキュリティの向上、新機能の向上を図るために、最新バージョンの GitHub Enterprise にアップグレードします。 アップグレードに関するヘルプについては、GitHub Enterprise サポートにお問い合わせください

REST API ドキュメントの一部は最近移動されました。 探しているものが見つからない場合は、新しい Branches, Collaborators, Commits, Deploy Keys, Deployments, GitHub Pages, Releases, Metrics, Webhooks REST API ページを試してみてください。

デプロイ ブランチ ポリシー

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

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

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

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

List deployment branch policies

に対応 GitHub Apps

Lists the deployment branch policies for an environment.

Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.

"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. The name is not case sensitive.

environment_name string 必須

The name of the environment.

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

The number of results per page (max 100).

Default: 30

page integer

Page number of the results to fetch.

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>" \ http(s)://HOSTNAME/api/v3/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

に対応 GitHub Apps

Creates a deployment branch policy for an environment.

You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the administration:write permission for the repository to use this endpoint.

"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. The name is not case sensitive.

environment_name string 必須

The name of the environment.

本文のパラメーター
名前, 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.

"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>" \ http(s)://HOSTNAME/api/v3/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

に対応 GitHub Apps

Gets a deployment branch policy for an environment.

Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.

"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. The name is not case sensitive.

environment_name string 必須

The name of the environment.

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>" \ http(s)://HOSTNAME/api/v3/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

に対応 GitHub Apps

Updates a deployment branch policy for an environment.

You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the administration:write permission for the repository to use this endpoint.

"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. The name is not case sensitive.

environment_name string 必須

The name of the environment.

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>" \ http(s)://HOSTNAME/api/v3/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

に対応 GitHub Apps

Deletes a deployment branch policy for an environment.

You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the administration:write permission for the repository to use this endpoint.

"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. The name is not case sensitive.

environment_name string 必須

The name of the environment.

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>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID

Response

Status: 204