Skip to main content
Publicamos atualizações frequentes em nossa documentação, e a tradução desta página ainda pode estar em andamento. Para obter as informações mais atualizadas, acesse a documentação em inglês.

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

Funciona com GitHub Apps

Parâmetros para "List deploy keys"

Cabeçalhos
Name, Tipo, Descrição
accept string

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

Parâmetros de caminho
Name, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository. The name is not case sensitive.

Parâmetros de consulta
Name, Tipo, Descrição
per_page integer

The number of results per page (max 100).

Padrão: 30

page integer

Page number of the results to fetch.

Padrão: 1

Códigos de status de resposta HTTP para "List deploy keys"

Código de statusDescrição
200

OK

Exemplos de código para "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

Create a deploy key

Funciona com GitHub Apps

You can create a read-only deploy key.

Parâmetros para "Create a deploy key"

Cabeçalhos
Name, Tipo, Descrição
accept string

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

Parâmetros de caminho
Name, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository. The name is not case sensitive.

Parâmetros do corpo
Name, Tipo, Descrição
title string

A name for the key.

key string Obrigatório

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."

Códigos de status de resposta HTTP para "Create a deploy key"

Código de statusDescrição
201

Created

422

Validation failed, or the endpoint has been spammed.

Exemplos de código para "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 }

Get a deploy key

Funciona com GitHub Apps

Parâmetros para "Get a deploy key"

Cabeçalhos
Name, Tipo, Descrição
accept string

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

Parâmetros de caminho
Name, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository. The name is not case sensitive.

key_id integer Obrigatório

The unique identifier of the key.

Códigos de status de resposta HTTP para "Get a deploy key"

Código de statusDescrição
200

OK

404

Resource not found

Exemplos de código para "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 }

Delete a deploy key

Funciona com GitHub Apps

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
Name, Tipo, Descrição
accept string

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

Parâmetros de caminho
Name, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository. The name is not case sensitive.

key_id integer Obrigatório

The unique identifier of the key.

Códigos de status de resposta HTTP para "Delete a deploy key"

Código de statusDescrição
204

No Content

Exemplos de código para "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