Los despliegues son slicitudes para desplegar una ref específica (rma, SHA, etiqueta). GitHub despliega un evento de deployment
al que puedan escuchar los servicios externos y al con el cual puedan actuar cuando se creen los despliegues nuevos. Los despliegues habilitan a los desarrolladores y a las organizaciones para crear herramientas sin conexión directa en torno a los despliegues, sin tener que preocuparse acerca de los detalles de implementación de entregar tipos de aplicaciones diferentes (por ejemplo, web o nativas).
Los estados de despliegue permiten que los servicios externos marquen estos despliegues con un estado de error
, failure
, pending
, in_progress
, queued
, o success
que pueden consumir los sistemas que escuchan a los eventos de deployment_status
.
Los estados de despliegue también incluyen una description
y una log_url
opcionales, las cuales se recomiendan ampliamente, ya que hacen que los estados de despliegue sean más útiles. La log_url
es la URL completa para la salida del despliegue, y la description
es el resumen de alto nivel de lo que pasó con este despliegue.
GitHub envía eventos de deployment
y deployment_status
cuando se crean despliegues y estados de despliegue nuevos. Estos eventos permiten que las integraciones de terceros reciban respuesta de las solicitudes de despliegue y actualizan el estado de un despliegue conforme éste progrese.
Debajo encontrarás un diagrama de secuencia simple que explica cómo funcionarían estas interacciones.
+---------+ +--------+ +-----------+ +-------------+
| Tooling | | GitHub | | 3rd Party | | Your Server |
+---------+ +--------+ +-----------+ +-------------+
| | | |
| Create Deployment | | |
|--------------------->| | |
| | | |
| Deployment Created | | |
|<---------------------| | |
| | | |
| | Deployment Event | |
| |---------------------->| |
| | | SSH+Deploys |
| | |-------------------->|
| | | |
| | Deployment Status | |
| |<----------------------| |
| | | |
| | | Deploy Completed |
| | |<--------------------|
| | | |
| | Deployment Status | |
| |<----------------------| |
| | | |
Ten en cuenta que GitHub jamás accede a tus servidores realmente. La interacción con los eventos de despliegue dependerá de tu integración de terceros. Varios sistemas pueden escuchar a los eventos de despliegue, y depende de cada uno de ellos decidir si son responsables de cargar el código a tus servidores, si crean código nativo, etc.
Toma en cuenta que el Alcance de OAuth de repo_deployment
otorga acceso dirigido para los despliegues y estados de despliegue sin otorgar acceso al código del repositorio, mientras que los alcances de public_repo
yrepo
también otorgan permisos para el código.
Despliegues inactivos
Cuando configuras el estado de un despliegue como success
, entonces todos los despliegues anteriores que no sean transitorios ni de producción y que se encuentren en el mismo repositorio con el mismo ambiente se convertirán en inactive
. Para evitar esto, puedes configurar a auto_inactive
como false
cuando creas el estado del servidor.
Puedes comunicar que un ambiente transitorio ya no existe si configuras el state
como inactive
. El configurar al state
como inactive
muestra el despliegue como destroyed
en GitHub y elimina el acceso al mismo.
get /repos/{owner}/{repo}/deployments
Parámetros
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to
|
owner |
string | path | |
repo |
string | path | |
sha |
string | query |
The SHA recorded at creation time. Default:none |
ref |
string | query |
The name of the ref. This can be a branch, tag, or SHA. Default:none |
task |
string | query |
The name of the task for the deployment (e.g., none |
environment |
string | query |
The name of the environment that was deployed to (e.g., none |
per_page |
integer | query |
Results per page (max 100) Default:30 |
page |
integer | query |
Page number of the results to fetch. Default:1 |
Ejemplos de código
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/deployments
JavaScript (@octokit/core.js)
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
}
]
Notes
Aviso de previsualización
The inactive
state and the log_url
, environment_url
, and auto_inactive
parameters are currently available for developers to preview. Please see the blog post for full details.
To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.ant-man-preview+json
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 Enterprise Server 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
master
in 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
Parámetros
Name | Type | In | Description |
---|---|---|---|
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., deploy |
auto_merge |
boolean | body |
Attempts to automatically merge the default branch into the requested ref, if it's behind the default branch. Default:true |
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 | body |
JSON payload with extra information about the deployment. |
environment |
string | body |
Name for the target deployment environment (e.g., production |
description |
string or nullable | body |
Short description of the deployment. Default:
|
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: false |
production_environment |
boolean | body |
Specifies if the given environment is one that end-users directly interact with. Default: |
Ejemplos de código
Shell
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/deployments \
-d '{"ref":"ref"}'
JavaScript (@octokit/core.js)
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 Conflict
Validation failed
Status: 422 Unprocessable Entity
Notes
Aviso de previsualización
The inactive
state and the log_url
, environment_url
, and auto_inactive
parameters are currently available for developers to preview. Please see the blog post for full details.
To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.ant-man-preview+json
get /repos/{owner}/{repo}/deployments/{deployment_id}
Parámetros
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to
|
owner |
string | path | |
repo |
string | path | |
deployment_id |
integer | path |
deployment_id parameter |
Ejemplos de código
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/deployments/42
JavaScript (@octokit/core.js)
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
Notes
Avisos de previsualización
New features in the Deployments API on GitHub are currently available during a public beta. Please see the blog post for full details.
To access the new environment
parameter, the two new values for the state
parameter (in_progress
and queued
), and use auto_inactive
on production deployments during the public beta period, you must provide the following custom media type in the Accept
header:
application/vnd.github.flash-preview+json
The inactive
state and the log_url
, environment_url
, and auto_inactive
parameters are currently available for developers to preview. Please see the blog post for full details.
To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.ant-man-preview+json
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}
Parámetros
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to
|
owner |
string | path | |
repo |
string | path | |
deployment_id |
integer | path |
deployment_id parameter |
Ejemplos de código
Shell
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/deployments/42
JavaScript (@octokit/core.js)
await octokit.request('DELETE /repos/{owner}/{repo}/deployments/{deployment_id}', {
owner: 'octocat',
repo: 'hello-world',
deployment_id: 42
})
Response
Status: 204 No Content
Resource not found
Status: 404 Not Found
Validation failed
Status: 422 Unprocessable Entity
Notes
Estados de despliegue
get /repos/{owner}/{repo}/deployments/{deployment_id}/statuses
Parámetros
Name | Type | In | Description |
---|---|---|---|
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) Default:30 |
page |
integer | query |
Page number of the results to fetch. Default:1 |
Ejemplos de código
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/deployments/42/statuses
JavaScript (@octokit/core.js)
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
Notes
Avisos de previsualización
New features in the Deployments API on GitHub are currently available during a public beta. Please see the blog post for full details.
To access the new environment
parameter, the two new values for the state
parameter (in_progress
and queued
), and use auto_inactive
on production deployments during the public beta period, you must provide the following custom media type in the Accept
header:
application/vnd.github.flash-preview+json
The inactive
state and the log_url
, environment_url
, and auto_inactive
parameters are currently available for developers to preview. Please see the blog post for full details.
To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.ant-man-preview+json
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
Parámetros
Name | Type | In | Description |
---|---|---|---|
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. Default:
|
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 |
Ejemplos de código
Shell
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/deployments/42/statuses \
-d '{"state":"state"}'
JavaScript (@octokit/core.js)
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
Notes
Avisos de previsualización
New features in the Deployments API on GitHub are currently available during a public beta. Please see the blog post for full details.
To access the new environment
parameter, the two new values for the state
parameter (in_progress
and queued
), and use auto_inactive
on production deployments during the public beta period, you must provide the following custom media type in the Accept
header:
application/vnd.github.flash-preview+json
The inactive
state and the log_url
, environment_url
, and auto_inactive
parameters are currently available for developers to preview. Please see the blog post for full details.
To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.ant-man-preview+json
get /repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id}
Parámetros
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to
|
owner |
string | path | |
repo |
string | path | |
deployment_id |
integer | path |
deployment_id parameter |
status_id |
integer | path |
Ejemplos de código
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/deployments/42/statuses/42
JavaScript (@octokit/core.js)
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
Notes
Avisos de previsualización
New features in the Deployments API on GitHub are currently available during a public beta. Please see the blog post for full details.
To access the new environment
parameter, the two new values for the state
parameter (in_progress
and queued
), and use auto_inactive
on production deployments during the public beta period, you must provide the following custom media type in the Accept
header:
application/vnd.github.flash-preview+json
The inactive
state and the log_url
, environment_url
, and auto_inactive
parameters are currently available for developers to preview. Please see the blog post for full details.
To access the API during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.ant-man-preview+json
Llaves de implementación
Puedes lanzar proyectos hacia tu servidor desde un repositorio de tu instancia de GitHub Enterprise Server utilizando una llave de despliegue, la cual es una llave SSH que otorga acceso a un repositorio único. GitHub Enterprise Server adjunta la parte pública de la llave directamente en tu repositorio en vez de hacerlo a una cuenta de usuario, y la parte privada de ésta permanece en tu servidor. Para obtener más información, consulta la sección "Entregar despliegues".
Las llaves de despliegue pueden ya sea configurarse utilizando las siguientes terminales de la API, o mediante GitHub. Para aprender cómo configurar las llaves de despliegue en GitHub, consulta la sección "Administrar las llaves de despliegue".
get /repos/{owner}/{repo}/keys
Parámetros
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to
|
owner |
string | path | |
repo |
string | path | |
per_page |
integer | query |
Results per page (max 100) Default:30 |
page |
integer | query |
Page number of the results to fetch. Default:1 |
Ejemplos de código
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/keys
JavaScript (@octokit/core.js)
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
}
]
Notes
post /repos/{owner}/{repo}/keys
Parámetros
Name | Type | In | Description |
---|---|---|---|
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." |
Ejemplos de código
Shell
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/keys \
-d '{"key":"key"}'
JavaScript (@octokit/core.js)
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
Notes
get /repos/{owner}/{repo}/keys/{key_id}
Parámetros
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to
|
owner |
string | path | |
repo |
string | path | |
key_id |
integer | path |
key_id parameter |
Ejemplos de código
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/keys/42
JavaScript (@octokit/core.js)
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
Notes
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}
Parámetros
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to
|
owner |
string | path | |
repo |
string | path | |
key_id |
integer | path |
key_id parameter |
Ejemplos de código
Shell
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/keys/42
JavaScript (@octokit/core.js)
await octokit.request('DELETE /repos/{owner}/{repo}/keys/{key_id}', {
owner: 'octocat',
repo: 'hello-world',
key_id: 42
})
Response
Status: 204 No Content