Skip to main content

GitHub AE es una versión limitada en este momento.

Recientemente hemos movido parte de la documentación de la API REST. Si no encuentras lo que estás buscando, puedes probar las nuevas páginas de la API REST Branches, Collaborators, Commits, Deploy Keys, Deployments, GitHub Pages, Releases, Metrics, Webhooks.

Directivas de rama de implementación

Usa la API REST para administrar directivas de rama de implementación personalizadas.

Acerca de las directivas de rama de implementación

Puedes usar la API REST para especificar patrones de nombre personalizados que las ramas deben cumplir con el fin de implementarse en un entorno. La propiedad deployment_branch_policy.custom_branch_policies del entorno debe establecerse en true para usar estos puntos de conexión. Para actualizar deployment_branch_policy para un entorno, consulta "Entornos de implementación".

Para más información sobre cómo restringir las implementaciones de entorno a determinadas ramas, consulta "Utilizar ambientes para el despliegue".

List deployment branch policies

Funciona con 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.

Parámetros para "List deployment branch policies"

Encabezados
Nombre, Tipo, Descripción
accept string

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

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
owner string Requerido

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

repo string Requerido

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

environment_name string Requerido

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

Parámetros de consulta
Nombre, Tipo, Descripción
per_page integer

The number of results per page (max 100).

Valor predeterminado: 30

page integer

Page number of the results to fetch.

Valor predeterminado: 1

Códigos de estado de respuesta HTTP para "List deployment branch policies"

status codeDescripción
200

OK

Ejemplos de código para "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>" \ https://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

Funciona con GitHub Apps

Creates a deployment branch or tag 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.

Parámetros para "Create a deployment branch policy"

Encabezados
Nombre, Tipo, Descripción
accept string

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

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
owner string Requerido

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

repo string Requerido

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

environment_name string Requerido

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

Parámetros del cuerpo
Nombre, Tipo, Descripción
name string Requerido

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

Puede ser uno de los siguientes: branch, tag

Códigos de estado de respuesta HTTP para "Create a deployment branch policy"

status codeDescripción
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

Ejemplos de código para "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>" \ https://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

Funciona con GitHub Apps

Gets a deployment branch or tag 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.

Parámetros para "Get a deployment branch policy"

Encabezados
Nombre, Tipo, Descripción
accept string

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

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
owner string Requerido

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

repo string Requerido

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

environment_name string Requerido

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 Requerido

The unique identifier of the branch policy.

Códigos de estado de respuesta HTTP para "Get a deployment branch policy"

status codeDescripción
200

OK

Ejemplos de código para "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>" \ https://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

Funciona con GitHub Apps

Updates a deployment branch or tag 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.

Parámetros para "Update a deployment branch policy"

Encabezados
Nombre, Tipo, Descripción
accept string

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

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
owner string Requerido

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

repo string Requerido

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

environment_name string Requerido

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 Requerido

The unique identifier of the branch policy.

Parámetros del cuerpo
Nombre, Tipo, Descripción
name string Requerido

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.

Códigos de estado de respuesta HTTP para "Update a deployment branch policy"

status codeDescripción
200

OK

Ejemplos de código para "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>" \ https://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

Funciona con GitHub Apps

Deletes a deployment branch or tag 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.

Parámetros para "Delete a deployment branch policy"

Encabezados
Nombre, Tipo, Descripción
accept string

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

Parámetros de la ruta de acceso
Nombre, Tipo, Descripción
owner string Requerido

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

repo string Requerido

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

environment_name string Requerido

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 Requerido

The unique identifier of the branch policy.

Códigos de estado de respuesta HTTP para "Delete a deployment branch policy"

status codeDescripción
204

No Content

Ejemplos de código para "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>" \ https://HOSTNAME/api/v3/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID

Response

Status: 204