Недавно мы перенесли некоторые из документации по REST API. Если вам не удается найти нужный объект, попробуйте использовать новые страницы REST API Branches, Collaborators, Commits, Deploy Keys, Deployments, GitHub Pages, Releases, Metrics, Webhooks.
Политики ветвей развертывания
Используйте REST API для управления настраиваемыми политиками ветви развертывания.
Сведения о политиках ветви развертывания
С помощью REST API можно указать настраиваемые шаблоны имен, которым должны соответствовать ветви для развертывания в среде. Необходимо задать свойство true
для среды, чтобы разрешить deployment_branch_policy.custom_branch_policies
использовать эти конечные точки. Сведения об обновлении для среды см. в 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"
Заголовки |
---|
Имя, Тип, Описание |
accept stringSetting to |
Параметры пути |
Имя, Тип, Описание |
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. |
Параметры запроса |
Имя, Тип, Описание |
per_page integerThe number of results per page (max 100). Значение по умолчанию: |
page integerPage number of the results to fetch. Значение по умолчанию: |
Коды состояния HTTP-ответа для "List deployment branch policies"
Код состояния | Описание |
---|---|
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"
Заголовки |
---|
Имя, Тип, Описание |
accept stringSetting to |
Параметры пути |
Имя, Тип, Описание |
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. |
Параметры запроса |
Имя, Тип, Описание |
name stringОбязательноThe name pattern that branches must match in order to deploy to the environment. Wildcard characters will not match |
Коды состояния HTTP-ответа для "Create a deployment branch policy"
Код состояния | Описание |
---|---|
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"
Заголовки |
---|
Имя, Тип, Описание |
accept stringSetting to |
Параметры пути |
Имя, Тип, Описание |
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. |
Коды состояния HTTP-ответа для "Get a deployment branch policy"
Код состояния | Описание |
---|---|
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"
Заголовки |
---|
Имя, Тип, Описание |
accept stringSetting to |
Параметры пути |
Имя, Тип, Описание |
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. |
Параметры запроса |
Имя, Тип, Описание |
name stringОбязательноThe name pattern that branches must match in order to deploy to the environment. Wildcard characters will not match |
Коды состояния HTTP-ответа для "Update a deployment branch policy"
Код состояния | Описание |
---|---|
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"
Заголовки |
---|
Имя, Тип, Описание |
accept stringSetting to |
Параметры пути |
Имя, Тип, Описание |
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. |
Коды состояния HTTP-ответа для "Delete a deployment branch policy"
Код состояния | Описание |
---|---|
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