Chaves de implantação
Use a API REST para criar e gerenciar chaves de implantação.
Sobre as chaves de implantação
É possível iniciar projetos por meio de um repositório no sua instância do GitHub Enterprise Server com relação ao servidor usando uma chave de implantação, que é uma chave SSH que concede acesso a um só repositório. GitHub Enterprise Server anexa a parte pública da chave diretamente ao repositório em vez de uma conta pessoal, e a parte privada da chave permanece no seu servidor. Para obter mais informações, confira "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 chaves de implantação no GitHub, confira "Gerenciar chaves de implantação".
List deploy keys
Parâmetros para "List deploy keys"
Cabeçalhos |
---|
Nome, Type, Descrição |
accept string Setting to |
Parâmetros de caminho |
Nome, Type, 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. The name is not case sensitive. |
Parâmetros de consulta |
Nome, Type, Descrição |
per_page integer The number of results per page (max 100). Padrão: |
page integer Page number of the results to fetch. Padrão: |
Códigos de status de resposta HTTP para "List deploy keys"
Código de status | Descrição |
---|---|
200 | OK |
Exemplos de código para "List deploy 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
You can create a read-only deploy key.
Parâmetros para "Create a deploy key"
Cabeçalhos |
---|
Nome, Type, Descrição |
accept string Setting to |
Parâmetros de caminho |
Nome, Type, 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. The name is not case sensitive. |
Parâmetros do corpo |
Nome, Type, Descrição |
title string A name for the key. |
key string ObrigatórioThe contents of the key. |
read_only boolean If 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." |
Códigos de status de resposta HTTP para "Create a deploy key"
Código de status | Descrição |
---|---|
201 | Created |
422 | Validation failed, or the endpoint has been spammed. |
Exemplos de código para "Create a deploy key"
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
Parâmetros para "Get a deploy key"
Cabeçalhos |
---|
Nome, Type, Descrição |
accept string Setting to |
Parâmetros de caminho |
Nome, Type, 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. The name is not case sensitive. |
key_id integer ObrigatórioThe unique identifier of the key. |
Códigos de status de resposta HTTP para "Get a deploy key"
Código de status | Descrição |
---|---|
200 | OK |
404 | Resource not found |
Exemplos de código para "Get a deploy key"
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
Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.
Parâmetros para "Delete a deploy key"
Cabeçalhos |
---|
Nome, Type, Descrição |
accept string Setting to |
Parâmetros de caminho |
Nome, Type, 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. The name is not case sensitive. |
key_id integer ObrigatórioThe unique identifier of the key. |
Códigos de status de resposta HTTP para "Delete a deploy key"
Código de status | Descrição |
---|---|
204 | No Content |
Exemplos de código para "Delete a deploy key"
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