デプロイメントとは、特定の ref (ブランチ、SHA、タグ) を配備するためるリクエストです。 GitHub は、 外部サーバーがリッスンでき、新しいデプロイメントが作成されたときに実行される deployment イベントをディスバッチします。 デプロイメントにより、開発者や Organization はデプロイメントを中心として、さまざまな種類のアプリケーション (ウェブ、ネイティブなど) を提供するための実装に関する詳細を気にすることなく、疎結合ツールを構築できます。
デプロイメントのステータスを使用すると、外部サービスがデプロイメントに error、failure、pending、in_progress、queued、success ステータスを付けることができ、deployment_status イベントをリッスンするシステムがその情報を使用できます。
デプロイメントのステータスには、オプションとして description と log_url を含めることもできます。これによりデプロイメントのステータスがより有用なものになるので、非常におすすめです。 log_url はデプロイメントの出力の完全な URL で、description はデプロイメントで発生したことの概要を示すものです。
GitHub は、新しいデプロイメント、デプロイメントのステータスが作成されたときに、deployment イベント、deployment_status イベントをディスパッチします。 これらのイベントにより、サードパーティのインテグレーションがデプロイメントのリクエストに対する応答を受けとり、進展があるたびにステータスを更新できます。
以下は、これらの相互作用がどのように機能するかを示す簡単なシーケンス図です。
+---------+ +--------+ +-----------+ +-------------+
| Tooling | | GitHub | | 3rd Party | | Your Server |
+---------+ +--------+ +-----------+ +-------------+
| | | |
| Create Deployment | | |
|--------------------->| | |
| | | |
| Deployment Created | | |
|<---------------------| | |
| | | |
| | Deployment Event | |
| |---------------------->| |
| | | SSH+Deploys |
| | |-------------------->|
| | | |
| | Deployment Status | |
| |<----------------------| |
| | | |
| | | Deploy Completed |
| | |<--------------------|
| | | |
| | Deployment Status | |
| |<----------------------| |
| | | |
GitHub は、あなたのサーバーに実際にアクセスすることはないということは覚えておきましょう。 デプロイメントイベントとやり取りするかどうかは、サードパーティインテグレーション次第です。 複数のシステムがデプロイメントイベントをリッスンできます。コードをサーバーにプッシュする、ネイティブコードを構築するなどを行うかどうかは、それぞれのシステムが決めることができます。
Note that the repo_deployment OAuth scope grants targeted access to deployments and deployment statuses without granting access to repository code, while the public_repo andrepo scopes grant permission to code as well.
非アクティブのデプロイメント
When you set the state of a deployment to success, then all prior non-transient, non-production environment deployments in the same repository with the same environment name will become inactive. これを回避するには、デプロイメントのステータスを作成する前に、auto_inactive を false に設定します。
state を inactive に設定することで、一時的な環境が存在しなくなったことを伝えることができます。 state を inactive に設定すると、GitHub でデプロイメントが destroyed と表示され、アクセス権が削除されます。
List deployments
Simple filtering of deployments is available via query parameters:
get /repos/{owner}/{repo}/deploymentsパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
sha | string | query | The SHA recorded at creation time. デフォルト: |
ref | string | query | The name of the ref. This can be a branch, tag, or SHA. デフォルト: |
task | string | query | The name of the task for the deployment (e.g., デフォルト: |
environment | string | query | The name of the environment that was deployed to (e.g., デフォルト: |
per_page | integer | query | Results per page (max 100) デフォルト: |
page | integer | query | Page number of the results to fetch. デフォルト: |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/deployments await octokit.request('GET /repos/{owner}/{repo}/deployments', {
owner: 'octocat',
repo: 'hello-world'
})Response
Status: 200 OK [
{
"url": "https://api.github.com/repos/octocat/example/deployments/1",
"id": 1,
"node_id": "MDEwOkRlcGxveW1lbnQx",
"sha": "a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d",
"ref": "topic-branch",
"task": "deploy",
"payload": {},
"original_environment": "staging",
"environment": "production",
"description": "Deploy request from hubot",
"creator": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2012-07-20T01:19:13Z",
"updated_at": "2012-07-20T01:19:13Z",
"statuses_url": "https://api.github.com/repos/octocat/example/deployments/1/statuses",
"repository_url": "https://api.github.com/repos/octocat/example",
"transient_environment": false,
"production_environment": true
}
]注釈
Create a deployment
Deployments offer a few configurable parameters with certain defaults.
The ref parameter can be any named branch, tag, or SHA. At GitHub we often deploy branches and verify them
before we merge a pull request.
The environment parameter allows deployments to be issued to different runtime environments. Teams often have
multiple environments for verifying their applications, such as production, staging, and qa. This parameter
makes it easier to track which environments have requested deployments. The default environment is production.
The auto_merge parameter is used to ensure that the requested ref is not behind the repository's default branch. If
the ref is behind the default branch for the repository, we will attempt to merge it for you. If the merge succeeds,
the API will return a successful merge commit. If merge conflicts prevent the merge from succeeding, the API will
return a failure response.
By default, commit statuses for every submitted context must be in a success
state. The required_contexts parameter allows you to specify a subset of contexts that must be success, or to
specify contexts that have not yet been submitted. You are not required to use commit statuses to deploy. If you do
not require any contexts or create any commit statuses, the deployment will always succeed.
The payload parameter is available for any extra information that a deployment system might need. It is a JSON text
field that will be passed on when a deployment event is dispatched.
The task parameter is used by the deployment system to allow different execution paths. In the web world this might
be deploy:migrations to run schema changes on the system. In the compiled world this could be a flag to compile an
application with debugging enabled.
Users with repo or repo_deployment scopes can create a deployment for a given ref.
Merged branch response
You will see this response when GitHub automatically merges the base branch into the topic branch instead of creating a deployment. This auto-merge happens when:
- Auto-merge option is enabled in the repository
- Topic branch does not include the latest changes on the base branch, which is
masterin the response example - There are no merge conflicts
If there are no new commits in the base branch, a new request to create a deployment should give a successful response.
Merge conflict response
This error happens when the auto_merge option is enabled and when the default branch (in this case master), can't
be merged into the branch that's being deployed (in this case topic-branch), due to merge conflicts.
Failed commit status checks
This error happens when the required_contexts parameter indicates that one or more contexts need to have a success
status for the commit to be deployed, but one or more of the required contexts do not have a state of success.
post /repos/{owner}/{repo}/deploymentsパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
ref | string | body | Required. The ref to deploy. This can be a branch, tag, or SHA. |
task | string | body | Specifies a task to execute (e.g., デフォルト: |
auto_merge | boolean | body | Attempts to automatically merge the default branch into the requested ref, if it's behind the default branch. デフォルト: |
required_contexts | array of strings | body | The status contexts to verify against commit status checks. If you omit this parameter, GitHub verifies all unique contexts before creating a deployment. To bypass checking entirely, pass an empty array. Defaults to all unique contexts. |
payload | object or string or | body | JSON payload with extra information about the deployment. |
environment | string | body | Name for the target deployment environment (e.g., デフォルト: |
description | string or null | body | Short description of the deployment. |
transient_environment | boolean | body | Specifies if the given environment is specific to the deployment and will no longer exist at some point in the future. Default: |
production_environment | boolean | body | Specifies if the given environment is one that end-users directly interact with. Default: |
コードサンプル
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/deployments \
-d '{"ref":"ref"}' await octokit.request('POST /repos/{owner}/{repo}/deployments', {
owner: 'octocat',
repo: 'hello-world',
ref: 'ref'
})Simple example
Status: 201 Created {
"url": "https://api.github.com/repos/octocat/example/deployments/1",
"id": 1,
"node_id": "MDEwOkRlcGxveW1lbnQx",
"sha": "a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d",
"ref": "topic-branch",
"task": "deploy",
"payload": {},
"original_environment": "staging",
"environment": "production",
"description": "Deploy request from hubot",
"creator": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2012-07-20T01:19:13Z",
"updated_at": "2012-07-20T01:19:13Z",
"statuses_url": "https://api.github.com/repos/octocat/example/deployments/1/statuses",
"repository_url": "https://api.github.com/repos/octocat/example",
"transient_environment": false,
"production_environment": true
}Merged branch response
Status: 202 Accepted {
"message": "Auto-merged master into topic-branch on deployment."
}Conflict when there is a merge conflict or the commit's status checks failed
Status: 409 ConflictValidation failed
Status: 422 Unprocessable Entity注釈
Get a deployment
get /repos/{owner}/{repo}/deployments/{deployment_id}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
deployment_id | integer | path | deployment_id parameter |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/deployments/42 await octokit.request('GET /repos/{owner}/{repo}/deployments/{deployment_id}', {
owner: 'octocat',
repo: 'hello-world',
deployment_id: 42
})Response
Status: 200 OK {
"url": "https://api.github.com/repos/octocat/example/deployments/1",
"id": 1,
"node_id": "MDEwOkRlcGxveW1lbnQx",
"sha": "a84d88e7554fc1fa21bcbc4efae3c782a70d2b9d",
"ref": "topic-branch",
"task": "deploy",
"payload": {},
"original_environment": "staging",
"environment": "production",
"description": "Deploy request from hubot",
"creator": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2012-07-20T01:19:13Z",
"updated_at": "2012-07-20T01:19:13Z",
"statuses_url": "https://api.github.com/repos/octocat/example/deployments/1/statuses",
"repository_url": "https://api.github.com/repos/octocat/example",
"transient_environment": false,
"production_environment": true
}Resource not found
Status: 404 Not Found注釈
Delete a deployment
If the repository only has one deployment, you can delete the deployment regardless of its status. If the repository has more than one deployment, you can only delete inactive deployments. This ensures that repositories with multiple deployments will always have an active deployment. Anyone with repo or repo_deployment scopes can delete a deployment.
To set a deployment as inactive, you must:
- Create a new deployment that is active so that the system has a record of the current state, then delete the previously active deployment.
- Mark the active deployment as inactive by adding any non-successful deployment status.
For more information, see "Create a deployment" and "Create a deployment status."
delete /repos/{owner}/{repo}/deployments/{deployment_id}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
deployment_id | integer | path | deployment_id parameter |
コードサンプル
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/deployments/42 await octokit.request('DELETE /repos/{owner}/{repo}/deployments/{deployment_id}', {
owner: 'octocat',
repo: 'hello-world',
deployment_id: 42
})Response
Status: 204 No ContentResource not found
Status: 404 Not FoundValidation failed
Status: 422 Unprocessable Entity注釈
環境
Environments APIを使うと、環境を作成、設定、削除できます。 For more information about environments, see "Using environments for deployment." 環境のシークレットの管理については「シークレット」を参照してください。
Environments, environment protection rules, and environment secrets are available in public repositories for all products. For access to environments in private repositories, you must use GitHub Enterprise. 詳しい情報については「GitHubの製品」を参照してください。
Get all environments
Get all environments for a repository.
Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.
get /repos/{owner}/{repo}/environmentsパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/environments await octokit.request('GET /repos/{owner}/{repo}/environments', {
owner: 'octocat',
repo: 'hello-world'
})Response
Status: 200 OK {
"total_count": 1,
"environments": [
{
"id": 161088068,
"node_id": "MDExOkVudmlyb25tZW50MTYxMDg4MDY4",
"name": "staging",
"url": "https://api.github.com/repos/github/hello-world/environments/staging",
"html_url": "https://github.com/github/hello-world/deployments/activity_log?environments_filter=staging",
"created_at": "2020-11-23T22:00:40Z",
"updated_at": "2020-11-23T22:00:40Z",
"protection_rules": [
{
"id": 3736,
"node_id": "MDQ6R2F0ZTM3MzY=",
"type": "wait_timer",
"wait_timer": 30
},
{
"id": 3755,
"node_id": "MDQ6R2F0ZTM3NTU=",
"type": "required_reviewers",
"reviewers": [
{
"type": "User",
"reviewer": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
}
},
{
"type": "Team",
"reviewer": {
"id": 1,
"node_id": "MDQ6VGVhbTE=",
"url": "https://api.github.com/teams/1",
"html_url": "https://github.com/orgs/github/teams/justice-league",
"name": "Justice League",
"slug": "justice-league",
"description": "A great team.",
"privacy": "closed",
"permission": "admin",
"members_url": "https://api.github.com/teams/1/members{/member}",
"repositories_url": "https://api.github.com/teams/1/repos",
"parent": null
}
}
]
},
{
"id": 3756,
"node_id": "MDQ6R2F0ZTM3NTY=",
"type": "branch_policy"
}
],
"deployment_branch_policy": {
"protected_branches": false,
"custom_branch_policies": true
}
}
]
}注釈
Get an environment
Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.
get /repos/{owner}/{repo}/environments/{environment_name}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
environment_name | string | path | The name of the environment |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/environments/ENVIRONMENT_NAME await octokit.request('GET /repos/{owner}/{repo}/environments/{environment_name}', {
owner: 'octocat',
repo: 'hello-world',
environment_name: 'environment_name'
})Response
Status: 200 OK {
"id": 161088068,
"node_id": "MDExOkVudmlyb25tZW50MTYxMDg4MDY4",
"name": "staging",
"url": "https://api.github.com/repos/github/hello-world/environments/staging",
"html_url": "https://github.com/github/hello-world/deployments/activity_log?environments_filter=staging",
"created_at": "2020-11-23T22:00:40Z",
"updated_at": "2020-11-23T22:00:40Z",
"protection_rules": [
{
"id": 3736,
"node_id": "MDQ6R2F0ZTM3MzY=",
"type": "wait_timer",
"wait_timer": 30
},
{
"id": 3755,
"node_id": "MDQ6R2F0ZTM3NTU=",
"type": "required_reviewers",
"reviewers": [
{
"type": "User",
"reviewer": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
}
},
{
"type": "Team",
"reviewer": {
"id": 1,
"node_id": "MDQ6VGVhbTE=",
"url": "https://api.github.com/teams/1",
"html_url": "https://github.com/orgs/github/teams/justice-league",
"name": "Justice League",
"slug": "justice-league",
"description": "A great team.",
"privacy": "closed",
"permission": "admin",
"members_url": "https://api.github.com/teams/1/members{/member}",
"repositories_url": "https://api.github.com/teams/1/repos",
"parent": null
}
}
]
},
{
"id": 3756,
"node_id": "MDQ6R2F0ZTM3NTY=",
"type": "branch_policy"
}
],
"deployment_branch_policy": {
"protected_branches": false,
"custom_branch_policies": true
}
}注釈
Create or update an environment
Create or update an environment with protection rules, such as required reviewers. For more information about environment protection rules, see "Environments."
Note: Although you can use this operation to specify that only branches that match specified name patterns can deploy to this environment, you must use the UI to set the name patterns. For more information, see "Environments."
Note: To create or update secrets for an environment, see "Secrets."
You must authenticate using an access token with the repo scope to use this endpoint.
put /repos/{owner}/{repo}/environments/{environment_name}パラメータ
| 名前 | 種類 | In | 説明 | ||||||
|---|---|---|---|---|---|---|---|---|---|
accept | string | header | Setting to | ||||||
owner | string | path | |||||||
repo | string | path | |||||||
environment_name | string | path | The name of the environment | ||||||
wait_timer | integer | body | The amount of time to delay a job after the job is initially triggered. The time (in minutes) must be an integer between 0 and 43,200 (30 days). | ||||||
reviewers | array of objects or null | body | The people or teams that may review jobs that reference the environment. You can list up to six users or teams as reviewers. The reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed. | ||||||
Properties of the | |||||||||
| 名前 (種類) | 説明 |
|---|---|
type (string) | The type of reviewer. Must be one of: |
id (integer) | The id of the user or team who can review the deployment |
deployment_branch_policyThe type of deployment branch policy for this environment. To allow all branches to deploy, set to null.
Properties of thedeployment_branch_policyobject
| 名前 (種類) | 説明 |
|---|---|
protected_branches (boolean) | Required. Whether only branches with branch protection rules can deploy to this environment. If |
custom_branch_policies (boolean) | Required. Whether only branches that match the specified name patterns can deploy to this environment. If |
コードサンプル
curl \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/environments/ENVIRONMENT_NAME \
-d '{"wait_timer":42}' await octokit.request('PUT /repos/{owner}/{repo}/environments/{environment_name}', {
owner: 'octocat',
repo: 'hello-world',
environment_name: 'environment_name',
wait_timer: 42
})Response
Status: 200 OK {
"id": 161088068,
"node_id": "MDExOkVudmlyb25tZW50MTYxMDg4MDY4",
"name": "staging",
"url": "https://api.github.com/repos/github/hello-world/environments/staging",
"html_url": "https://github.com/github/hello-world/deployments/activity_log?environments_filter=staging",
"created_at": "2020-11-23T22:00:40Z",
"updated_at": "2020-11-23T22:00:40Z",
"protection_rules": [
{
"id": 3736,
"node_id": "MDQ6R2F0ZTM3MzY=",
"type": "wait_timer",
"wait_timer": 30
},
{
"id": 3755,
"node_id": "MDQ6R2F0ZTM3NTU=",
"type": "required_reviewers",
"reviewers": [
{
"type": "User",
"reviewer": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
}
},
{
"type": "Team",
"reviewer": {
"id": 1,
"node_id": "MDQ6VGVhbTE=",
"url": "https://api.github.com/teams/1",
"html_url": "https://github.com/orgs/github/teams/justice-league",
"name": "Justice League",
"slug": "justice-league",
"description": "A great team.",
"privacy": "closed",
"permission": "admin",
"members_url": "https://api.github.com/teams/1/members{/member}",
"repositories_url": "https://api.github.com/teams/1/repos",
"parent": null
}
}
]
},
{
"id": 3756,
"node_id": "MDQ6R2F0ZTM3NTY=",
"type": "branch_policy"
}
],
"deployment_branch_policy": {
"protected_branches": false,
"custom_branch_policies": true
}
}Validation error when the environment name is invalid or when protected_branches and custom_branch_policies in deployment_branch_policy are set to the same value
Status: 422 Unprocessable Entity注釈
Delete an environment
You must authenticate using an access token with the repo scope to use this endpoint.
delete /repos/{owner}/{repo}/environments/{environment_name}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
environment_name | string | path | The name of the environment |
コードサンプル
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/environments/ENVIRONMENT_NAME await octokit.request('DELETE /repos/{owner}/{repo}/environments/{environment_name}', {
owner: 'octocat',
repo: 'hello-world',
environment_name: 'environment_name'
})Default response
Status: 204 No Content注釈
デプロイキー
You can launch projects from a repository on GitHub.com to your server by using a deploy key, which is an SSH key that grants access to a single repository. GitHubは個人ユーザアカウントの代わりに、リポジトリに直接キーのパブリックな部分をアタッチし、キーのプライベートな部分はサーバーに残ります。 詳しい情報については「デプロイメントのデリバリー」を参照してください。
デプロイキーは、以下の API エンドポイントを使用するか、GitHub を使用することでセットアップできます。 GitHub でデプロイキーを設定する方法については、「デプロイキーを管理する」を参照してください。
List deploy keys
get /repos/{owner}/{repo}/keysパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
per_page | integer | query | Results per page (max 100) デフォルト: |
page | integer | query | Page number of the results to fetch. デフォルト: |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/keys await octokit.request('GET /repos/{owner}/{repo}/keys', {
owner: 'octocat',
repo: 'hello-world'
})Response
Status: 200 OK [
{
"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
You can create a read-only deploy key.
post /repos/{owner}/{repo}/keysパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
title | string | body | A name for the key. |
key | string | body | Required. The contents of the key. |
read_only | boolean | body | 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." |
コードサンプル
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/keys \
-d '{"key":"key"}' await octokit.request('POST /repos/{owner}/{repo}/keys', {
owner: 'octocat',
repo: 'hello-world',
key: 'key'
})Response
Status: 201 Created {
"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
}Validation failed
Status: 422 Unprocessable Entity注釈
Get a deploy key
get /repos/{owner}/{repo}/keys/{key_id}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
key_id | integer | path | key_id parameter |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/keys/42 await octokit.request('GET /repos/{owner}/{repo}/keys/{key_id}', {
owner: 'octocat',
repo: 'hello-world',
key_id: 42
})Response
Status: 200 OK {
"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
}Resource not found
Status: 404 Not Found注釈
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 /repos/{owner}/{repo}/keys/{key_id}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
key_id | integer | path | key_id parameter |
コードサンプル
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/keys/42 await octokit.request('DELETE /repos/{owner}/{repo}/keys/{key_id}', {
owner: 'octocat',
repo: 'hello-world',
key_id: 42
})Response
Status: 204 No Content注釈
List deployment statuses
Users with pull access can view deployment statuses for a deployment:
get /repos/{owner}/{repo}/deployments/{deployment_id}/statusesパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
deployment_id | integer | path | deployment_id parameter |
per_page | integer | query | Results per page (max 100) デフォルト: |
page | integer | query | Page number of the results to fetch. デフォルト: |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/deployments/42/statuses await octokit.request('GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses', {
owner: 'octocat',
repo: 'hello-world',
deployment_id: 42
})Response
Status: 200 OK [
{
"url": "https://api.github.com/repos/octocat/example/deployments/42/statuses/1",
"id": 1,
"node_id": "MDE2OkRlcGxveW1lbnRTdGF0dXMx",
"state": "success",
"creator": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"description": "Deployment finished successfully.",
"environment": "production",
"target_url": "https://example.com/deployment/42/output",
"created_at": "2012-07-20T01:19:13Z",
"updated_at": "2012-07-20T01:19:13Z",
"deployment_url": "https://api.github.com/repos/octocat/example/deployments/42",
"repository_url": "https://api.github.com/repos/octocat/example",
"environment_url": "https://test-branch.lab.acme.com",
"log_url": "https://example.com/deployment/42/output"
}
]Resource not found
Status: 404 Not Found注釈
Create a deployment status
Users with push access can create deployment statuses for a given deployment.
GitHub Apps require read & write access to "Deployments" and read-only access to "Repo contents" (for private repos). OAuth Apps require the repo_deployment scope.
post /repos/{owner}/{repo}/deployments/{deployment_id}/statusesパラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
deployment_id | integer | path | deployment_id parameter |
state | string | body | Required. The state of the status. Can be one of |
target_url | string | body | The target URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. Note: It's recommended to use the |
log_url | string | body | The full URL of the deployment's output. This parameter replaces |
description | string | body | A short description of the status. The maximum description length is 140 characters. |
environment | string | body | Name for the target deployment environment, which can be changed when setting a deploy status. For example, |
environment_url | string | body | Sets the URL for accessing your environment. Default: |
auto_inactive | boolean | body | Adds a new |
コードサンプル
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/deployments/42/statuses \
-d '{"state":"state"}' await octokit.request('POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses', {
owner: 'octocat',
repo: 'hello-world',
deployment_id: 42,
state: 'state'
})Response
Status: 201 Created {
"url": "https://api.github.com/repos/octocat/example/deployments/42/statuses/1",
"id": 1,
"node_id": "MDE2OkRlcGxveW1lbnRTdGF0dXMx",
"state": "success",
"creator": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"description": "Deployment finished successfully.",
"environment": "production",
"target_url": "https://example.com/deployment/42/output",
"created_at": "2012-07-20T01:19:13Z",
"updated_at": "2012-07-20T01:19:13Z",
"deployment_url": "https://api.github.com/repos/octocat/example/deployments/42",
"repository_url": "https://api.github.com/repos/octocat/example",
"environment_url": "https://test-branch.lab.acme.com",
"log_url": "https://example.com/deployment/42/output"
}Validation failed
Status: 422 Unprocessable Entity注釈
Get a deployment status
Users with pull access can view a deployment status for a deployment:
get /repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id}パラメータ
| 名前 | 種類 | In | 説明 |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
deployment_id | integer | path | deployment_id parameter |
status_id | integer | path |
コードサンプル
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/deployments/42/statuses/42 await octokit.request('GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id}', {
owner: 'octocat',
repo: 'hello-world',
deployment_id: 42,
status_id: 42
})Response
Status: 200 OK {
"url": "https://api.github.com/repos/octocat/example/deployments/42/statuses/1",
"id": 1,
"node_id": "MDE2OkRlcGxveW1lbnRTdGF0dXMx",
"state": "success",
"creator": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"description": "Deployment finished successfully.",
"environment": "production",
"target_url": "https://example.com/deployment/42/output",
"created_at": "2012-07-20T01:19:13Z",
"updated_at": "2012-07-20T01:19:13Z",
"deployment_url": "https://api.github.com/repos/octocat/example/deployments/42",
"repository_url": "https://api.github.com/repos/octocat/example",
"environment_url": "https://test-branch.lab.acme.com",
"log_url": "https://example.com/deployment/42/output"
}Resource not found
Status: 404 Not Found