このバージョンの GitHub Enterprise サーバーはこの日付をもって終了となります: 2026-08-25. 廃止されたリリースはサポートされていません。 重大なセキュリティの問題に対してであっても、パッチリリースは作成されません。 GitHub Enterprise Server のパフォーマンスの向上、セキュリティの向上、新機能については、「アップグレード プロセスの概要を参照してください。 アップグレードに関するサポートについては、GitHub Enterprise Support にお問い合わせください。
デプロイ キー用の REST API エンドポイント
REST API を使って、デプロイ キーの作成と管理を行います。
デプロイ キーについて
デプロイ キーを使用すると、お使いの GitHub Enterprise Server インスタンス のリポジトリからサーバーにプロジェクトを起動できます。デプロイ キーは、単一のリポジトリへのアクセス権を付与する SSH キーです。 GitHub は個人アカウントの代わりに、リポジトリに直接キーのパブリックな部分をアタッチし、キーのプライベートな部分はサーバーに残ります。 詳しくは、「デプロイメントを配信する」をご覧ください。
デプロイ キーは、次の API エンドポイントを使用するか、 GitHub Web インターフェイスを使用して設定できます。 Web インターフェイスで配置キーを設定する方法を確認するには、「デプロイキーの管理」を参照してください。
Organization または Enterprise 所有者が使用を制限するポリシーを設定している場合、デプロイ キーを作成できない場合があります。 さらに、このポリシーが Organization または Enterprise レベルで有効になっている場合は、既存のデプロイ キーが無効になる可能性があります。 詳細については、「Enterprise でリポジトリ管理ポリシーを適用する」および「組織内のデプロイ キーを制限する」を参照してください。
他のアクティビティによってデプロイ キーが削除される場合がいくつかあります。
- personal access tokenを使用してデプロイ キーが作成された場合、personal access tokenを削除すると、デプロイ キーも削除されます。 personal access tokenを再生成すると、デプロイ キーは削除されません。
- OAuth app トークンを使用してデプロイ キーが作成された場合、トークンを取り消すと、デプロイ キーも削除されます。
逆に、次のアクティビティはデプロイ キーを削除しません。
- GitHub Appユーザー アクセス トークンを使用してデプロイ キーが作成された場合、トークンを取り消してもデプロイ キーは削除されません。
- 展開キーが GitHub App インストール アクセス トークンを使用して作成された場合、アプリをアンインストールまたは削除しても、展開キーは削除されません。
- personal access tokenを使用してデプロイ キーが作成された場合、personal access tokenを再生成しても、デプロイ キーは削除されません。
List deploy keys
"List deploy keys" のきめ細かいアクセス トークン
このエンドポイントは、次の粒度の細かいトークンの種類で動作します:
粒度の細かいトークンには次のアクセス許可セットが設定されている必要があります:
- "Administration" repository permissions (read)
"List deploy keys" のパラメーター
| 名前, タイプ, 説明 |
|---|
accept string Setting to |
| 名前, タイプ, 説明 |
|---|
owner string 必須The account owner of the repository. The name is not case sensitive. |
repo string 必須The name of the repository without the |
| 名前, タイプ, 説明 |
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." デフォルト: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." デフォルト: |
"List deploy keys" の HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
200 | OK |
"List deploy keys" のコード サンプル
要求の例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keysResponse
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,
"added_by": "octocat",
"last_used": "2022-01-10T15:53:42Z",
"enabled": true
}
]Create a deploy key
You can create a read-only deploy key.
"Create a deploy key" のきめ細かいアクセス トークン
このエンドポイントは、次の粒度の細かいトークンの種類で動作します:
粒度の細かいトークンには次のアクセス許可セットが設定されている必要があります:
- "Administration" repository permissions (write)
"Create a deploy key" のパラメーター
| 名前, タイプ, 説明 |
|---|
accept string Setting to |
| 名前, タイプ, 説明 |
|---|
owner string 必須The account owner of the repository. The name is not case sensitive. |
repo string 必須The name of the repository without the |
| 名前, タイプ, 説明 |
|---|
title string A name for the key. |
key string 必須The 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." |
"Create a deploy key" の HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
201 | Created |
422 | Validation failed, or the endpoint has been spammed. |
"Create a deploy key" のコード サンプル
要求の例
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
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,
"added_by": "octocat",
"last_used": "2022-01-10T15:53:42Z",
"enabled": true
}Get a deploy key
"Get a deploy key" のきめ細かいアクセス トークン
このエンドポイントは、次の粒度の細かいトークンの種類で動作します:
粒度の細かいトークンには次のアクセス許可セットが設定されている必要があります:
- "Administration" repository permissions (read)
"Get a deploy key" のパラメーター
| 名前, タイプ, 説明 |
|---|
accept string Setting to |
| 名前, タイプ, 説明 |
|---|
owner string 必須The account owner of the repository. The name is not case sensitive. |
repo string 必須The name of the repository without the |
key_id integer 必須The unique identifier of the key. |
"Get a deploy key" の HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
200 | OK |
404 | Resource not found |
"Get a deploy key" のコード サンプル
要求の例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys/KEY_IDResponse
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,
"added_by": "octocat",
"last_used": "2022-01-10T15:53:42Z",
"enabled": 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.
"Delete a deploy key" のきめ細かいアクセス トークン
このエンドポイントは、次の粒度の細かいトークンの種類で動作します:
粒度の細かいトークンには次のアクセス許可セットが設定されている必要があります:
- "Administration" repository permissions (write)
"Delete a deploy key" のパラメーター
| 名前, タイプ, 説明 |
|---|
accept string Setting to |
| 名前, タイプ, 説明 |
|---|
owner string 必須The account owner of the repository. The name is not case sensitive. |
repo string 必須The name of the repository without the |
key_id integer 必須The unique identifier of the key. |
"Delete a deploy key" の HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
204 | No Content |
"Delete a deploy key" のコード サンプル
要求の例
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/keys/KEY_IDResponse
Status: 204