Esta versão do GitHub Enterprise foi descontinuada em 2022-06-03. Nenhum lançamento de patch será feito, mesmo para questões críticas de segurança. Para obter melhor desempenho, melhorar a segurança e novos recursos, upgrade to the latest version of GitHub Enterprise. Para ajuda com a atualização, contact GitHub Enterprise support.
Chaves de implantação
A API de chaves de implantação permite criar e gerenciar chaves de implantação.
Sobre a API de chaves de implantação
You can launch projects from a repository on your GitHub Enterprise Server instance to your server by using a deploy key, which is an SSH key that grants access to a single repository. GitHub Enterprise Server attaches the public part of the key directly to your repository instead of a personal account, and the private part of the key remains on your server. Para obter mais informações, consulte "Entregar implantações".
Chaves de implantação podem ser configuradas usando os seguintes pontos de extremidades da API ou usando o GitHub. Para saber como configurar as chaves de implantação no GitHub, consulte "Gerenciar chaves de implantação".
List deploy keys
Parâmetros
| Headers |
|---|
| Nome, Tipo, Descrição |
acceptstringSetting to |
| Path parameters |
| Nome, Tipo, Descrição |
ownerstringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repostringObrigatórioThe name of the repository. The name is not case sensitive. |
| Parâmetros de consulta |
| Nome, Tipo, Descrição |
per_pageintegerThe number of results per page (max 100). Padrão: |
pageintegerPage number of the results to fetch. Padrão: |
HTTP response status codes
| Status code | Descrição |
|---|---|
200 | OK |
Amostras de código
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keysResponse
Status: 200[
{
"id": 1,
"key": "ssh-rsa AAA...",
"url": "https://api.github.com/repos/octocat/Hello-World/keys/1",
"title": "octocat@octomac",
"verified": true,
"created_at": "2014-12-10T15:53:42Z",
"read_only": true
}
]Create a deploy key
You can create a read-only deploy key.
Parâmetros
| Headers |
|---|
| Nome, Tipo, Descrição |
acceptstringSetting to |
| Path parameters |
| Nome, Tipo, Descrição |
ownerstringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repostringObrigatórioThe name of the repository. The name is not case sensitive. |
| Body parameters |
| Nome, Tipo, Descrição |
titlestringA name for the key. |
keystringObrigatórioThe contents of the key. |
read_onlybooleanIf 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 response status codes
| Status code | Descrição |
|---|---|
201 | Created |
422 | Validation failed |
Amostras de código
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <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://api.github.com/repos/octocat/Hello-World/keys/1",
"title": "octocat@octomac",
"verified": true,
"created_at": "2014-12-10T15:53:42Z",
"read_only": true
}Get a deploy key
Parâmetros
| Headers |
|---|
| Nome, Tipo, Descrição |
acceptstringSetting to |
| Path parameters |
| Nome, Tipo, Descrição |
ownerstringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repostringObrigatórioThe name of the repository. The name is not case sensitive. |
key_idintegerObrigatórioThe unique identifier of the key. |
HTTP response status codes
| Status code | Descrição |
|---|---|
200 | OK |
404 | Resource not found |
Amostras de código
curl \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys/KEY_IDResponse
Status: 200{
"id": 1,
"key": "ssh-rsa AAA...",
"url": "https://api.github.com/repos/octocat/Hello-World/keys/1",
"title": "octocat@octomac",
"verified": true,
"created_at": "2014-12-10T15:53:42Z",
"read_only": true
}Delete a deploy key
Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.
Parâmetros
| Headers |
|---|
| Nome, Tipo, Descrição |
acceptstringSetting to |
| Path parameters |
| Nome, Tipo, Descrição |
ownerstringObrigatórioThe account owner of the repository. The name is not case sensitive. |
repostringObrigatórioThe name of the repository. The name is not case sensitive. |
key_idintegerObrigatórioThe unique identifier of the key. |
HTTP response status codes
| Status code | Descrição |
|---|---|
204 | No Content |
Amostras de código
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys/KEY_IDResponse
Status: 204