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 your GitHub Enterprise Server instance 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 "Como 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, consulte "Como gerenciar chaves de implantação".
List deploy keys
Parameters
Headers |
---|
Nome, Type, Descrição |
accept stringSetting to |
Path parameters |
Nome, Type, Descrição |
owner stringRequiredThe account owner of the repository. The name is not case sensitive. |
repo stringRequiredThe name of the repository. The name is not case sensitive. |
Query parameters |
Nome, Type, Descrição |
per_page integerThe number of results per page (max 100). Default: |
page integerPage number of the results to fetch. Default: |
HTTP response status codes
Status code | Descrição |
---|---|
200 | OK |
Code samples
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys
Response
Status: 200
{}
Create a deploy key
You can create a read-only deploy key.
Parameters
Headers |
---|
Nome, Type, Descrição |
accept stringSetting to |
Path parameters |
Nome, Type, Descrição |
owner stringRequiredThe account owner of the repository. The name is not case sensitive. |
repo stringRequiredThe name of the repository. The name is not case sensitive. |
Body parameters |
Nome, Type, Descrição |
title stringA name for the key. |
key stringRequiredThe contents of the key. |
read_only booleanIf 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, or the endpoint has been spammed. |
Code samples
curl \
-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://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
Parameters
Headers |
---|
Nome, Type, Descrição |
accept stringSetting to |
Path parameters |
Nome, Type, Descrição |
owner stringRequiredThe account owner of the repository. The name is not case sensitive. |
repo stringRequiredThe name of the repository. The name is not case sensitive. |
key_id integerRequiredThe unique identifier of the key. |
HTTP response status codes
Status code | Descrição |
---|---|
200 | OK |
404 | Resource not found |
Code samples
curl \
-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://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.
Parameters
Headers |
---|
Nome, Type, Descrição |
accept stringSetting to |
Path parameters |
Nome, Type, Descrição |
owner stringRequiredThe account owner of the repository. The name is not case sensitive. |
repo stringRequiredThe name of the repository. The name is not case sensitive. |
key_id integerRequiredThe unique identifier of the key. |
HTTP response status codes
Status code | Descrição |
---|---|
204 | No Content |
Code samples
curl \
-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