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
Paramètres pour « List deploy keys »
En-têtes |
---|
Nom, Type, Description |
accept string Setting to |
Paramètres de chemin d’accès |
Nom, Type, Description |
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe 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: |
page integer Page number of the results to fetch. Default: |
Codes d’état de la réponse HTTP pour « List deploy keys »
Code d’état | Description |
---|---|
200 | OK |
Exemples de code pour « 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
{}
Create a deploy key
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 |
Paramètres de chemin d’accès |
Nom, Type, Description |
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe 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 ObligatoireThe 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." |
Codes d’état de la réponse HTTP pour « Create a deploy key »
Code d’état | Description |
---|---|
201 | Created |
422 | Validation failed, or the endpoint has been spammed. |
Exemples de code pour « 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
}
Get a deploy key
Paramètres pour « Get a deploy key »
En-têtes |
---|
Nom, Type, Description |
accept string Setting to |
Paramètres de chemin d’accès |
Nom, Type, Description |
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository. The name is not case sensitive. |
key_id integer ObligatoireThe unique identifier of the key. |
Codes d’état de la réponse HTTP pour « Get a deploy key »
Code d’état | Description |
---|---|
200 | OK |
404 | Resource not found |
Exemples de code pour « 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
}
Delete a deploy key
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 |
Paramètres de chemin d’accès |
Nom, Type, Description |
owner string ObligatoireThe account owner of the repository. The name is not case sensitive. |
repo string ObligatoireThe name of the repository. The name is not case sensitive. |
key_id integer ObligatoireThe unique identifier of the key. |
Codes d’état de la réponse HTTP pour « Delete a deploy key »
Code d’état | Description |
---|---|
204 | No Content |
Exemples de code pour « 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