Schlüssel bereitstellen
Verwende die REST-API, um Bereitstellungsschlüssel zu erstellen und zu verwalten.
Informationen zu Bereitstellungsschlüsseln
Du kannst Projekte aus einem Repository in deine GitHub Enterprise Server-Instanz auf deinem Server starten, indem du einen Bereitstellungsschlüssel verwendest. Dabei handelt es sich um einen SSH-Schlüssel, der Zugriff auf ein einzelnes Repository gewährt. GitHub Enterprise Server fügt den öffentlichen Teil des Schlüssels direkt an dein Repository anstatt an dein persönliches Konto an, und der private Teil des Schlüssels verbleibt auf deinem Server. Weitere Informationen findest du unter Übermitteln von Bereitstellungen.
Die Bereitstellung von Schlüsseln kann entweder mithilfe der folgenden API-Endpunkte oder über GitHub eingerichtet werden. Weitere Informationen zum Einrichten von Bereitstellungsschlüsseln in GitHub findest du unter Verwalten von Bereitstellungsschlüsseln.
List deploy keys
Parameter für „List deploy keys“
Header |
---|
Name, type, BESCHREIBUNG |
accept string Setting to |
Pfadparameter |
Name, type, BESCHREIBUNG |
owner string ErforderlichThe account owner of the repository. The name is not case sensitive. |
repo string ErforderlichThe name of the repository. The name is not case sensitive. |
Abfrageparameter |
Name, type, BESCHREIBUNG |
per_page integer The number of results per page (max 100). Standard: |
page integer Page number of the results to fetch. Standard: |
HTTP-Antwortstatuscodes für „List deploy keys“
Statuscode | BESCHREIBUNG |
---|---|
200 | OK |
Codebeispiele für „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.
Parameter für „Create a deploy key“
Header |
---|
Name, type, BESCHREIBUNG |
accept string Setting to |
Pfadparameter |
Name, type, BESCHREIBUNG |
owner string ErforderlichThe account owner of the repository. The name is not case sensitive. |
repo string ErforderlichThe name of the repository. The name is not case sensitive. |
Textparameter |
Name, type, BESCHREIBUNG |
title string A name for the key. |
key string ErforderlichThe 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." |
HTTP-Antwortstatuscodes für „Create a deploy key“
Statuscode | BESCHREIBUNG |
---|---|
201 | Created |
422 | Validation failed, or the endpoint has been spammed. |
Codebeispiele für „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
Parameter für „Get a deploy key“
Header |
---|
Name, type, BESCHREIBUNG |
accept string Setting to |
Pfadparameter |
Name, type, BESCHREIBUNG |
owner string ErforderlichThe account owner of the repository. The name is not case sensitive. |
repo string ErforderlichThe name of the repository. The name is not case sensitive. |
key_id integer ErforderlichThe unique identifier of the key. |
HTTP-Antwortstatuscodes für „Get a deploy key“
Statuscode | BESCHREIBUNG |
---|---|
200 | OK |
404 | Resource not found |
Codebeispiele für „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.
Parameter für „Delete a deploy key“
Header |
---|
Name, type, BESCHREIBUNG |
accept string Setting to |
Pfadparameter |
Name, type, BESCHREIBUNG |
owner string ErforderlichThe account owner of the repository. The name is not case sensitive. |
repo string ErforderlichThe name of the repository. The name is not case sensitive. |
key_id integer ErforderlichThe unique identifier of the key. |
HTTP-Antwortstatuscodes für „Delete a deploy key“
Statuscode | BESCHREIBUNG |
---|---|
204 | No Content |
Codebeispiele für „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