このバージョンの 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
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 |
パス パラメーター |
名前, 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: |
page integer Page number of the results to fetch. Default: |
"List deployment branch policies" の HTTP 応答状態コード
状態コード | 説明 |
---|---|
200 | OK |
"List 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
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 |
パス パラメーター |
名前, 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 |
"Create a deployment branch policy" の HTTP 応答状態コード
状態コード | 説明 |
---|---|
200 | OK |
303 | Response if the same branch name pattern already exists |
404 | Not Found or |
"Create a deployment branch policy" のコード サンプル
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
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 |
パス パラメーター |
名前, 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" のコード サンプル
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
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 |
パス パラメーター |
名前, 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 |
"Update a deployment branch policy" の HTTP 応答状態コード
状態コード | 説明 |
---|---|
200 | OK |
"Update a deployment branch policy" のコード サンプル
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
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 |
パス パラメーター |
名前, 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" のコード サンプル
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