Skip to main content
Мы публикуем частые обновления нашей документации, и перевод этой страницы может все еще выполняться. Актуальные сведения см. в документации на английском языке.

Ключи развертывания

Используйте REST API для создания ключей развертывания и управления ими.

Сведения о ключах развертывания

Вы можете запускать проекты из репозитория на экземпляр GitHub Enterprise Server на сервере с помощью ключа развертывания, который представляет собой ключ SSH, который предоставляет доступ к одному репозиторию. GitHub Enterprise Server присоединяет открытую часть ключа непосредственно к репозиторию, а не к личной учетной записи. Закрытая часть ключа при этом остается на сервере. Дополнительные сведения см. в разделе Доставка развертываний.

Ключи развертывания можно настраивать, используя либо указанные ниже конечные точки API, либо GitHub. Сведения о том, как настроить ключи развертывания в GitHub, см. в разделе Управление ключами развертывания.

List deploy keys

Работа с GitHub Apps

Параметры для "List deploy keys"

Заголовки
Имя, Тип, Описание
accept string

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

Параметры пути
Имя, Тип, Описание
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.

Параметры запроса
Имя, Тип, Описание
per_page integer

The number of results per page (max 100).

Значение по умолчанию: 30

page integer

Page number of the results to fetch.

Значение по умолчанию: 1

Коды состояния HTTP-ответа для "List deploy keys"

Код состоянияОписание
200

OK

Примеры кода для "List deploy keys"

get/repos/{owner}/{repo}/keys
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys

Response

Status: 200
[ { "id": 1, "key": "ssh-rsa AAA...", "url": "https://HOSTNAME/repos/octocat/Hello-World/keys/1", "title": "octocat@octomac", "verified": true, "created_at": "2014-12-10T15:53:42Z", "read_only": true, "added_by": "octocat", "last_used": "2022-01-10T15:53:42Z" } ]

Create a deploy key

Работа с GitHub Apps

You can create a read-only deploy key.

Параметры для "Create a deploy key"

Заголовки
Имя, Тип, Описание
accept string

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

Параметры пути
Имя, Тип, Описание
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.

Параметры запроса
Имя, Тип, Описание
title string

A name for the key.

key string Обязательно

The contents of the key.

read_only boolean

If true, the key will only be able to read repository contents. Otherwise, the key will be able to read and write.

Deploy keys with write access can perform the same actions as an organization member with admin access, or a collaborator on a personal repository. For more information, see "Repository permission levels for an organization" and "Permission levels for a user account repository."

Коды состояния HTTP-ответа для "Create a deploy key"

Код состоянияОписание
201

Created

422

Validation failed, or the endpoint has been spammed.

Примеры кода для "Create a deploy key"

post/repos/{owner}/{repo}/keys
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys \ -d '{"title":"octocat@octomac","key":"ssh-rsa AAA...","read_only":true}'

Response

Status: 201
{ "id": 1, "key": "ssh-rsa AAA...", "url": "https://HOSTNAME/repos/octocat/Hello-World/keys/1", "title": "octocat@octomac", "verified": true, "created_at": "2014-12-10T15:53:42Z", "read_only": true, "added_by": "octocat", "last_used": "2022-01-10T15:53:42Z" }

Get a deploy key

Работа с GitHub Apps

Параметры для "Get a deploy key"

Заголовки
Имя, Тип, Описание
accept string

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

Параметры пути
Имя, Тип, Описание
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.

key_id integer Обязательно

The unique identifier of the key.

Коды состояния HTTP-ответа для "Get a deploy key"

Код состоянияОписание
200

OK

404

Resource not found

Примеры кода для "Get a deploy key"

get/repos/{owner}/{repo}/keys/{key_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys/KEY_ID

Response

Status: 200
{ "id": 1, "key": "ssh-rsa AAA...", "url": "https://HOSTNAME/repos/octocat/Hello-World/keys/1", "title": "octocat@octomac", "verified": true, "created_at": "2014-12-10T15:53:42Z", "read_only": true, "added_by": "octocat", "last_used": "2022-01-10T15:53:42Z" }

Delete a deploy key

Работа с GitHub Apps

Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.

Параметры для "Delete a deploy key"

Заголовки
Имя, Тип, Описание
accept string

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

Параметры пути
Имя, Тип, Описание
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.

key_id integer Обязательно

The unique identifier of the key.

Коды состояния HTTP-ответа для "Delete a deploy key"

Код состоянияОписание
204

No Content

Примеры кода для "Delete a deploy key"

delete/repos/{owner}/{repo}/keys/{key_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys/KEY_ID

Response

Status: 204