Create a deployment
POST
/repos/{owner}/{repo}/deployments
repos
ref
parameter can be any named branch, tag, or SHA. At GitHub Enterprise Server we often deploy branches and verify thembefore we merge a pull request.
environment
parameter allows deployments to be issued to different runtime environments. Teams often havemultiple environments for verifying their applications, such as
production
, staging
, and qa
. This parametermakes it easier to track which environments have requested deployments. The default environment is
production
.auto_merge
parameter is used to ensure that the requested ref is not behind the repository's default branch. Ifthe 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.
success
state. The
required_contexts
parameter allows you to specify a subset of contexts that must be success
, or tospecify 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.
payload
parameter is available for any extra information that a deployment system might need. It is a JSON textfield that will be passed on when a deployment event is dispatched.
task
parameter is used by the deployment system to allow different execution paths. In the web world this mightbe
deploy:migrations
to run schema changes on the system. In the compiled world this could be a flag to compile anapplication with debugging enabled.
repo
or repo_deployment
scopes can create a deployment for a given ref.Merged branch response
a deployment. This auto-merge happens when:
master
in the response exampleresponse.
Merge conflict response
auto_merge
option is enabled and when the default branch (in this case master
), can'tbe merged into the branch that's being deployed (in this case
topic-branch
), due to merge conflicts.Failed commit status checks
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
.请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.github.com/repos///deployments' \
--header 'Content-Type: application/json' \
--data-raw '{
"auto_merge": false,
"description": "Deploy request from hubot",
"payload": "{ \"deploy\": \"migrate\" }",
"ref": "topic-branch",
"required_contexts": [
"ci/janky",
"security/brakeman"
]
}'
响应示例响应示例
201 - 示例 1
{
"created_at": "2012-07-20T01:19:13Z",
"description": "Deploy request from hubot",
"environment": "production",
"id": 42,
"node_id": "MDEwOkRlcGxveW1lbnQx",
"original_environment": "staging",
"performed_via_github_app": {},
"production_environment": true,
"repository_url": "https://api.github.com/repos/octocat/example",
"statuses_url": "https://api.github.com/repos/octocat/example/deployments/1/statuses",
"task": "deploy",
"transient_environment": true,
"updated_at": "2012-07-20T01:19:13Z",
"url": "https://api.github.com/repos/octocat/example/deployments/1"
}
请求参数
Path 参数
owner
string
必需
repo
string
必需
Body 参数application/json