Pontos de extremidade da API REST para regras de proteção
Use a API REST para criar, configurar e excluir regras de proteção de implantação.
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.
Tokens de acesso refinados para "Get all deployment protection rules for an environment"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
- Tokens de acesso de usuário do aplicativo GitHub
- Tokens de acesso à instalação do aplicativo GitHub
- Tokens de acesso pessoal refinados
O token refinado deve ter os seguintes conjuntos de permissões:
- "Actions" repository permissions (read)
Esse ponto de extremidade pode ser usado sem autenticação ou as permissões acima mencionadas se apenas recursos públicos forem solicitados.
Parâmetros para "Get all deployment protection rules for an environment"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
environment_name string ObrigatórioThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
repo string ObrigatórioThe name of the repository without the |
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
Códigos de status de resposta HTTP para "Get all deployment protection rules for an environment"
Código de status | Descrição |
---|---|
200 | List of deployment protection rules |
Exemplos de código para "Get all deployment protection rules for an environment"
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
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.
Tokens de acesso refinados para "Create a custom deployment protection rule on an environment"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
- Tokens de acesso de usuário do aplicativo GitHub
- Tokens de acesso à instalação do aplicativo GitHub
- Tokens de acesso pessoal refinados
O token refinado deve ter os seguintes conjuntos de permissões:
- "Administration" repository permissions (write)
Parâmetros para "Create a custom deployment protection rule on an environment"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
environment_name string ObrigatórioThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
repo string ObrigatórioThe name of the repository without the |
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
Nome, Tipo, Descrição |
---|
integration_id integer The ID of the custom app that will be enabled on the environment. |
Códigos de status de resposta HTTP para "Create a custom deployment protection rule on an environment"
Código de status | Descrição |
---|---|
201 | The enabled custom deployment protection rule |
Exemplos de código para "Create a custom deployment protection rule on an environment"
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
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.
Tokens de acesso refinados para "List custom deployment rule integrations available for an environment"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
- Tokens de acesso de usuário do aplicativo GitHub
- Tokens de acesso à instalação do aplicativo GitHub
- Tokens de acesso pessoal refinados
O token refinado deve ter os seguintes conjuntos de permissões:
- "Administration" repository permissions (read)
Parâmetros para "List custom deployment rule integrations available for an environment"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
environment_name string ObrigatórioThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
repo string ObrigatórioThe name of the repository without the |
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
Nome, Tipo, Descrição |
---|
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Padrão: |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Padrão: |
Códigos de status de resposta HTTP para "List custom deployment rule integrations available for an environment"
Código de status | Descrição |
---|---|
200 | A list of custom deployment rule integrations available for this environment. |
Exemplos de código para "List custom deployment rule integrations available for an environment"
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
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.
Tokens de acesso refinados para "Get a custom deployment protection rule"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
- Tokens de acesso de usuário do aplicativo GitHub
- Tokens de acesso à instalação do aplicativo GitHub
- Tokens de acesso pessoal refinados
O token refinado deve ter os seguintes conjuntos de permissões:
- "Actions" repository permissions (read)
Esse ponto de extremidade pode ser usado sem autenticação ou as permissões acima mencionadas se apenas recursos públicos forem solicitados.
Parâmetros para "Get a custom deployment protection rule"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
repo string ObrigatórioThe name of the repository without the |
environment_name string ObrigatórioThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
protection_rule_id integer ObrigatórioThe unique identifier of the protection rule. |
Códigos de status de resposta HTTP para "Get a custom deployment protection rule"
Código de status | Descrição |
---|---|
200 | OK |
Exemplos de código para "Get a custom deployment protection rule"
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
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.
Tokens de acesso refinados para "Disable a custom protection rule for an environment"
Esse ponto de extremidade funciona com os seguintes tipos de token refinados:
- Tokens de acesso de usuário do aplicativo GitHub
- Tokens de acesso à instalação do aplicativo GitHub
- Tokens de acesso pessoal refinados
O token refinado deve ter os seguintes conjuntos de permissões:
- "Administration" repository permissions (write)
Parâmetros para "Disable a custom protection rule for an environment"
Nome, Tipo, Descrição |
---|
accept string Setting to |
Nome, Tipo, Descrição |
---|
environment_name string ObrigatórioThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with |
repo string ObrigatórioThe name of the repository without the |
owner string ObrigatórioThe account owner of the repository. The name is not case sensitive. |
protection_rule_id integer ObrigatórioThe unique identifier of the protection rule. |
Códigos de status de resposta HTTP para "Disable a custom protection rule for an environment"
Código de status | Descrição |
---|---|
204 | No Content |
Exemplos de código para "Disable a custom protection rule for an environment"
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
Exemplo de solicitação
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