Skip to main content
Nous publions des mises à jour fréquentes de notre documentation, et la traduction de cette page peut encore être en cours. Pour obtenir les informations les plus actuelles, consultez la documentation anglaise.

Clés de déploiement

Utilisez l’API REST pour créer et gérer des clés de déploiement.

À propos des clés de déploiement

Vous pouvez lancer des projets à partir d’un référentiel sur votre instance GitHub Enterprise Server sur votre serveur à l’aide d’une clé de déploiement, qui est une clé SSH accordant l’accès à un seul référentiel. GitHub Enterprise Server attache la partie publique de la clé directement à votre dépôt, au lieu d’un compte personnel, tandis que la partie privée de la clé reste sur votre serveur. Pour plus d’informations, consultez « Livraison de déploiements ».

Les clés de déploiement peuvent être configurées avec les points de terminaison d’API suivants ou en utilisant GitHub. Pour savoir comment configurer des clés de déploiement dans GitHub, consultez « Gestion des clés de déploiement ».

List deploy keys

Compatible avec GitHub Apps

Paramètres pour « List deploy keys »

En-têtes
Nom, Type, Description
accept string

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

Paramètres de chemin d’accès
Nom, Type, Description
owner string Obligatoire

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

repo string Obligatoire

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

Paramètres de requête
Nom, Type, Description
per_page integer

The number of results per page (max 100).

Default: 30

page integer

Page number of the results to fetch.

Default: 1

Codes d’état de la réponse HTTP pour « List deploy keys »

Code d’étatDescription
200

OK

Exemples de code pour « 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

Compatible avec GitHub Apps

You can create a read-only deploy key.

Paramètres pour « Create a deploy key »

En-têtes
Nom, Type, Description
accept string

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

Paramètres de chemin d’accès
Nom, Type, Description
owner string Obligatoire

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

repo string Obligatoire

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

Paramètres du corps
Nom, Type, Description
title string

A name for the key.

key string Obligatoire

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

Codes d’état de la réponse HTTP pour « Create a deploy key »

Code d’étatDescription
201

Created

422

Validation failed, or the endpoint has been spammed.

Exemples de code pour « 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

Compatible avec GitHub Apps

Paramètres pour « Get a deploy key »

En-têtes
Nom, Type, Description
accept string

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

Paramètres de chemin d’accès
Nom, Type, Description
owner string Obligatoire

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

repo string Obligatoire

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

key_id integer Obligatoire

The unique identifier of the key.

Codes d’état de la réponse HTTP pour « Get a deploy key »

Code d’étatDescription
200

OK

404

Resource not found

Exemples de code pour « 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

Compatible avec GitHub Apps

Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.

Paramètres pour « Delete a deploy key »

En-têtes
Nom, Type, Description
accept string

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

Paramètres de chemin d’accès
Nom, Type, Description
owner string Obligatoire

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

repo string Obligatoire

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

key_id integer Obligatoire

The unique identifier of the key.

Codes d’état de la réponse HTTP pour « Delete a deploy key »

Code d’étatDescription
204

No Content

Exemples de code pour « 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