Skip to main content

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

Works with GitHub Apps

Parâmetros

Headers
Nome, Tipo, Descrição
acceptstring

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

Path parameters
Nome, Tipo, Descrição
ownerstringObrigatório

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

repostringObrigatório

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

Parâmetros de consulta
Nome, Tipo, Descrição
per_pageinteger

The number of results per page (max 100).

Padrão: 30

pageinteger

Page number of the results to fetch.

Padrão: 1

HTTP response status codes

Status codeDescrição
200

OK

Amostras de código

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

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 } ]

Create a deploy key

Works with GitHub Apps

You can create a read-only deploy key.

Parâmetros

Headers
Nome, Tipo, Descrição
acceptstring

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

Path parameters
Nome, Tipo, Descrição
ownerstringObrigatório

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

repostringObrigatório

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

Body parameters
Nome, Tipo, Descrição
titlestring

A name for the key.

keystringObrigatório

The contents of the key.

read_onlyboolean

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 response status codes

Status codeDescrição
201

Created

422

Validation failed

Amostras de código

post/repos/{owner}/{repo}/keys
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

Works with GitHub Apps

Parâmetros

Headers
Nome, Tipo, Descrição
acceptstring

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

Path parameters
Nome, Tipo, Descrição
ownerstringObrigatório

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

repostringObrigatório

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

key_idintegerObrigatório

The unique identifier of the key.

HTTP response status codes

Status codeDescrição
200

OK

404

Resource not found

Amostras de código

get/repos/{owner}/{repo}/keys/{key_id}
curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <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

Works with GitHub Apps

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
acceptstring

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

Path parameters
Nome, Tipo, Descrição
ownerstringObrigatório

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

repostringObrigatório

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

key_idintegerObrigatório

The unique identifier of the key.

HTTP response status codes

Status codeDescrição
204

No Content

Amostras de código

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

Response

Status: 204