Skip to main content
이제 REST API의 버전이 지정되었습니다. 자세한 내용은 "API 버전 관리 정보"를 참조하세요.

보호 규칙에 대한 REST API 엔드포인트

REST API를 사용하여 배포 보호 규칙을 만들고 구성하고 삭제합니다.

Get all deployment protection rules for an environment

Gets all custom deployment protection rules that are enabled for an environment. Anyone with read access to the repository can use this endpoint. For more information about environments, see "Using environments for deployment."

For more information about the app that is providing this custom deployment rule, see the documentation for the GET /apps/{app_slug} endpoint.

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

"Get all deployment protection rules for an environment"에 대한 세분화된 액세스 토큰

이 엔드포인트는 다음 세분화된 토큰 형식에서 작동합니다.:

세분화된 토큰에는 다음 권한 집합이 있어야 합니다.:

  • "Actions" repository permissions (read)

공용 리소스만 요청되는 경우 인증 또는 앞서 언급한 권한 없이 이 엔드포인트를 사용할 수 있습니다.

"Get all deployment protection rules for an environment"에 대한 매개 변수

머리글
속성, 형식, 설명
accept string

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

경로 매개 변수
속성, 형식, 설명
environment_name string Required

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

repo string Required

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

owner string Required

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

"Get all deployment protection rules for an environment"에 대한 HTTP 응답 상태 코드

상태 코드설명
200

List of deployment protection rules

"Get all deployment protection rules for an environment"에 대한 코드 샘플

GHE.com에서 GitHub에 액세스하는 경우 api.github.comapi.SUBDOMAIN.ghe.com의 엔터프라이즈 전용 하위 도메인으로 바꾸세요.

요청 예제

get/repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules
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_protection_rules

List of deployment protection rules

Status: 200
{ "total_count": 2, "custom_deployment_protection_rules": [ { "id": 3, "node_id": "IEH37kRlcGxveW1lbnRTdGF0ddiv", "enabled": true, "app": { "id": 1, "node_id": "GHT58kRlcGxveW1lbnRTdTY!bbcy", "slug": "a-custom-app", "integration_url": "https://api.github.com/apps/a-custom-app" } }, { "id": 4, "node_id": "MDE2OkRlcGxveW1lbnRTdHJ41128", "enabled": true, "app": { "id": 1, "node_id": "UHVE67RlcGxveW1lbnRTdTY!jfeuy", "slug": "another-custom-app", "integration_url": "https://api.github.com/apps/another-custom-app" } } ] }

Create a custom deployment protection rule on an environment

Enable a custom deployment protection rule for an environment.

The authenticated user must have admin or owner permissions to the repository to use this endpoint.

For more information about the app that is providing this custom deployment rule, see the documentation for the GET /apps/{app_slug} endpoint.

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

"Create a custom deployment protection rule on an environment"에 대한 세분화된 액세스 토큰

이 엔드포인트는 다음 세분화된 토큰 형식에서 작동합니다.:

세분화된 토큰에는 다음 권한 집합이 있어야 합니다.:

  • "Administration" repository permissions (write)

"Create a custom deployment protection rule on an environment"에 대한 매개 변수

머리글
속성, 형식, 설명
accept string

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

경로 매개 변수
속성, 형식, 설명
environment_name string Required

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

repo string Required

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

owner string Required

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

본문 매개 변수
속성, 형식, 설명
integration_id integer

The ID of the custom app that will be enabled on the environment.

"Create a custom deployment protection rule on an environment"에 대한 HTTP 응답 상태 코드

상태 코드설명
201

The enabled custom deployment protection rule

"Create a custom deployment protection rule on an environment"에 대한 코드 샘플

GHE.com에서 GitHub에 액세스하는 경우 api.github.comapi.SUBDOMAIN.ghe.com의 엔터프라이즈 전용 하위 도메인으로 바꾸세요.

요청 예제

post/repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules
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_protection_rules \ -d '{"integration_id":5}'

The enabled custom deployment protection rule

Status: 201
{ "id": 3, "node_id": "IEH37kRlcGxveW1lbnRTdGF0ddiv", "enabled": true, "app": { "id": 1, "node_id": "GHT58kRlcGxveW1lbnRTdTY!bbcy", "slug": "a-custom-app", "integration_url": "https://api.github.com/apps/a-custom-app" } }

List custom deployment rule integrations available for an environment

Gets all custom deployment protection rule integrations that are available for an environment.

The authenticated user must have admin or owner permissions to the repository to use this endpoint.

For more information about environments, see "Using environments for deployment."

For more information about the app that is providing this custom deployment rule, see "GET an app".

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

"List custom deployment rule integrations available for an environment"에 대한 세분화된 액세스 토큰

이 엔드포인트는 다음 세분화된 토큰 형식에서 작동합니다.:

세분화된 토큰에는 다음 권한 집합이 있어야 합니다.:

  • "Administration" repository permissions (read)

"List custom deployment rule integrations available for an environment"에 대한 매개 변수

머리글
속성, 형식, 설명
accept string

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

경로 매개 변수
속성, 형식, 설명
environment_name string Required

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

repo string Required

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

owner string Required

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

쿼리 매개 변수
속성, 형식, 설명
page integer

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

기본값: 1

per_page integer

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

기본값: 30

"List custom deployment rule integrations available for an environment"에 대한 HTTP 응답 상태 코드

상태 코드설명
200

A list of custom deployment rule integrations available for this environment.

"List custom deployment rule integrations available for an environment"에 대한 코드 샘플

GHE.com에서 GitHub에 액세스하는 경우 api.github.comapi.SUBDOMAIN.ghe.com의 엔터프라이즈 전용 하위 도메인으로 바꾸세요.

요청 예제

get/repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/apps
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_protection_rules/apps

A list of custom deployment rule integrations available for this environment.

Status: 200
[ { "total_count": 2 }, { "available_custom_deployment_protection_rule_integrations": [ { "id": 1, "node_id": "GHT58kRlcGxveW1lbnRTdTY!bbcy", "slug": "a-custom-app", "integration_url": "https://api.github.com/apps/a-custom-app" }, { "id": 2, "node_id": "UHVE67RlcGxveW1lbnRTdTY!jfeuy", "slug": "another-custom-app", "integration_url": "https://api.github.com/apps/another-custom-app" } ] } ]

Get a custom deployment protection rule

Gets an enabled custom deployment protection rule for an environment. Anyone with read access to the repository can use this endpoint. For more information about environments, see "Using environments for deployment."

For more information about the app that is providing this custom deployment rule, see GET /apps/{app_slug}.

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

"Get a custom deployment protection rule"에 대한 세분화된 액세스 토큰

이 엔드포인트는 다음 세분화된 토큰 형식에서 작동합니다.:

세분화된 토큰에는 다음 권한 집합이 있어야 합니다.:

  • "Actions" repository permissions (read)

공용 리소스만 요청되는 경우 인증 또는 앞서 언급한 권한 없이 이 엔드포인트를 사용할 수 있습니다.

"Get a custom deployment protection rule"에 대한 매개 변수

머리글
속성, 형식, 설명
accept string

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

경로 매개 변수
속성, 형식, 설명
owner string Required

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

repo string Required

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

environment_name string Required

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

protection_rule_id integer Required

The unique identifier of the protection rule.

"Get a custom deployment protection rule"에 대한 HTTP 응답 상태 코드

상태 코드설명
200

OK

"Get a custom deployment protection rule"에 대한 코드 샘플

GHE.com에서 GitHub에 액세스하는 경우 api.github.comapi.SUBDOMAIN.ghe.com의 엔터프라이즈 전용 하위 도메인으로 바꾸세요.

요청 예제

get/repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/{protection_rule_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_protection_rules/PROTECTION_RULE_ID

Response

Status: 200
{ "id": 3, "node_id": "IEH37kRlcGxveW1lbnRTdGF0ddiv", "enabled": true, "app": { "id": 1, "node_id": "GHT58kRlcGxveW1lbnRTdTY!bbcy", "slug": "a-custom-app", "integration_url": "https://api.github.com/apps/a-custom-app" } }

Disable a custom protection rule for an environment

Disables a custom deployment protection rule for an environment.

The authenticated user must have admin or owner permissions to the repository to use this endpoint.

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

"Disable a custom protection rule for an environment"에 대한 세분화된 액세스 토큰

이 엔드포인트는 다음 세분화된 토큰 형식에서 작동합니다.:

세분화된 토큰에는 다음 권한 집합이 있어야 합니다.:

  • "Administration" repository permissions (write)

"Disable a custom protection rule for an environment"에 대한 매개 변수

머리글
속성, 형식, 설명
accept string

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

경로 매개 변수
속성, 형식, 설명
environment_name string Required

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

repo string Required

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

owner string Required

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

protection_rule_id integer Required

The unique identifier of the protection rule.

"Disable a custom protection rule for an environment"에 대한 HTTP 응답 상태 코드

상태 코드설명
204

No Content

"Disable a custom protection rule for an environment"에 대한 코드 샘플

GHE.com에서 GitHub에 액세스하는 경우 api.github.comapi.SUBDOMAIN.ghe.com의 엔터프라이즈 전용 하위 도메인으로 바꾸세요.

요청 예제

delete/repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/{protection_rule_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_protection_rules/PROTECTION_RULE_ID

Response

Status: 204