Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 1, 2017. It is now read-only.

Commit0a177e1

Browse files
committed
Merge pull request#45 from github/deployments
Documentation for Deployments and Deployment Statuses
2 parentsacd1c7f +8e2d012 commit0a177e1

File tree

6 files changed

+310
-2
lines changed

6 files changed

+310
-2
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
kind:change
3+
title:Preview the New Deployments API
4+
created_at:2014-01-09
5+
author_name:atmos
6+
---
7+
8+
Today we're excited to announce a[Deployments API][docs]. We ship a lot of
9+
software at GitHub: web, mobile, and native. For the last few years, we've been
10+
driving our deployments from our[ChatOps tooling][chatops] and we've learned a
11+
lot. The Deployments API is a generalization of the approach that we've been
12+
taking, and we're really excited to see what our users and integrations start
13+
building around it.
14+
15+
Deployments are a new model in the GitHub ecosystem. We don't have any UI
16+
components currently, and deployments are intended to be used exclusively by
17+
tooling. If you're familiar with the Status API, you know that it allows
18+
various tools to report on the status of a commit (e.g., the progress of an
19+
attempt to perform a build at a particular commit). The Status API doesn't
20+
perform the build; it just reports the results. Much like the Status API, we
21+
won't be doing actual deployments for you. Instead, the API provides a way for
22+
you to track the status of your deployments. We're hoping to provide
23+
consistency across the various type of release processes, regardless of the
24+
underlying steps involved with getting your code built or shipped to your
25+
servers.
26+
27+
##Highlights
28+
29+
###Automatic Merging
30+
31+
The system can auto-merge the default branch for the repository if the
32+
requested deployment ref is behind the default branch. On active projects it's
33+
easy to fall behind, so let automation watch your back.
34+
35+
###Commit Status Integration
36+
37+
By default, the system rejects deployment requests for repositories that have
38+
commit statuses but don't have a green build for the deployment ref. This can
39+
be bypassed, but is useful in cases where continuous integration is being used.
40+
41+
###Force Deployments
42+
43+
Sometimes the world crashes down on you, and you need to just get the code out
44+
the door. Forced deployments bypass any commit status checks or ahead/behind
45+
checks in the repository.
46+
47+
###Deployment Statuses
48+
49+
Different deployment systems can update the status of a deployment to be
50+
`pending`,`success`,`failure`, or`error`. There's also a field for linking
51+
to deployment output.
52+
53+
###Events
54+
55+
Both Deployments and Deployment Statuses trigger events on GitHub. 3rd party
56+
integrations can listen for these events via[webhooks][hooks] and choose
57+
whether or not to actually deploy the repository that the event was created for.
58+
59+
##Preview Period
60+
61+
We're making this new API available today for developers to
62+
[preview][preview-mode]. We think developers and existing integrations are
63+
going to love it, but we want to[get your feedback][contact] before we declare
64+
the Deployments API "final" and "unchangeable." We expect the preview period to
65+
last for roughly 60-90 days.
66+
67+
As we discover opportunities to improve the API during the preview period, we
68+
may ship changes that break clients using the preview version of the API. We
69+
want to iterate quickly. To do so, we will announce any changes here (on the
70+
developer blog), but we will not provide any advance notice.
71+
72+
At the end of preview period, the Deployments API will become an official
73+
component of GitHub API v3. At that point, the new Deployments API will be
74+
stable and suitable for production use.
75+
76+
[docs]:/v3/repos/deployments/
77+
[hooks]:/v3/repos/hooks/
78+
[preview-mode]:/v3/repos/deployments/#preview-mode
79+
[chatops]:https://speakerdeck.com/jnewland/chatops
80+
[contact]:https://github.com/contact?form[subject]=Deployments+API

‎content/v3/repos/deployments.md

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
---
2+
title:Deployments | GitHub API
3+
---
4+
5+
#Deployments
6+
7+
* TOC
8+
{:toc}
9+
10+
<divclass="alert">
11+
<p>
12+
The Deployments API is currently available for developers to preview.
13+
During the preview period, the API may change without advance notice.
14+
Please see the <a href="/changes/2014-01-09-preview-the-new-deployments-api/">blog post</a> for full details.
15+
</p>
16+
17+
<p>
18+
To access the API during the preview period, you must provide a custom <a href="/v3/media">media type</a> in the <code>Accept</code> header:
19+
<pre>application/vnd.github.cannonball-preview+json</pre>
20+
</p>
21+
</div>
22+
23+
Deployments are a request for a specific ref(branch,sha,tag) to be deployed.
24+
GitHub then dispatches deployment events that external services can listen for
25+
and act on. This enables developers and organizations to build loosely-coupled
26+
tooling around deployments, without having to worry about implementation
27+
details of delivering different types of applications (e.g., web, native).
28+
29+
Deployment Statuses allow external services to mark deployments with a
30+
'success', 'failure', 'error', or 'pending' state, which can then be consumed
31+
by any system listening for`deployment_status` events.
32+
33+
Deployment Statuses can also include an optional`description` and`target_url`, and
34+
we highly recommend providing them as they make deployment statuses much more
35+
useful. The`target_url` would be the full URL to the deployment output, and
36+
the`description` would be the high level summary of what happened with the
37+
deployment.
38+
39+
Deployments and Deployment Statuses both have associated repository events when
40+
they're created. This allows web hooks and 3rd party integrations to respond to
41+
deployment requests as well as update the status of a deployment as progress is
42+
made.
43+
44+
Below is a simple sequence diagram for how these interactions would work.
45+
46+
<pre>
47+
+---------+ +--------+ +-----------+ +-------------+
48+
| Tooling | | GitHub | | 3rd Party | | Your Server |
49+
+---------+ +--------+ +-----------+ +-------------+
50+
| | | |
51+
| Create Deployment | | |
52+
|--------------------->| | |
53+
| | | |
54+
| Deployment Created | | |
55+
|<---------------------| | |
56+
| | | |
57+
| | Deployment Event | |
58+
| |---------------------->| |
59+
| | | SSH+Deploys |
60+
| | |-------------------->|
61+
| | | |
62+
| | Deployment Status | |
63+
| |<----------------------| |
64+
| | | |
65+
| | | Deploy Completed |
66+
| | |<--------------------|
67+
| | | |
68+
| | Deployment Status | |
69+
| |<----------------------| |
70+
| | | |
71+
</pre>
72+
73+
Keep in mind that GitHub is never actually accessing your servers. It's up to
74+
your 3rd party integration to interact with deployment events.
75+
This allows for[github-services](https://github.com/github/github-services)
76+
integrations as well as running your own systems depending on your use case.
77+
Multiple systems can listen for deployment events, and it's up to each of
78+
those systems to decide whether or not they're responsible for pushing the code
79+
out to your servers, building native code, etc.
80+
81+
Note that the`repo:deployment`[OAuth scope](/v3/oauth/#scopes) grants
82+
targeted access to Deployments and Deployment Statuses**without**
83+
granting access to repository code, while the`repo` scope grants permission to code
84+
as well.
85+
86+
##List Deployments
87+
88+
Users with pull access can view deployments for a repository:
89+
90+
GET /repos/:owner/:repo/deployments
91+
92+
###Response
93+
94+
<%= headers 200,:pagination => default_pagination_rels %>
95+
<%= json(:deployment) { |h|[h] } %>
96+
97+
##Create a Deployment
98+
99+
If your repository is taking advantage of[commit statuses](/v3/repos/statuses),
100+
the API will reject requests that do not have a success status. (Your repository
101+
is not required to use commit statuses. If no commit statuses are present, the
102+
deployment will always be created.)
103+
104+
The`force` parameter can be used when you really just need a deployment to go
105+
out. In these cases, all checks are bypassed, and the deployment is created for
106+
the ref.
107+
108+
The`auto_merge` parameter is used to ensure that the requested ref is not
109+
behind the repository's default branch. If the ref*is* behind the default
110+
branch for the repository, we will attempt to merge it for you. If the merge
111+
succeeds, the API will return a successful merge commit. If merge conflicts
112+
prevent the merge from succeeding, the API will return a failure response.
113+
114+
The`payload` parameter is available for any extra information that a
115+
deployment system might need. It is a JSON text field that will be passed on
116+
when a deployment event is dispatched.
117+
118+
Users with push access can create a deployment for a given ref:
119+
120+
POST /repos/:owner/:repo/deployments
121+
122+
###Parameters
123+
124+
Name | Type | Description
125+
-----|------|--------------
126+
`ref`|`string`|**Required**. The ref to deploy. This can be a branch, tag, or sha.
127+
`force`|`boolean`| Optional parameter to bypass any ahead/behind checks or commit status checks. Default:`false`
128+
`payload`|`string` | Optional JSON payload with extra information about the deployment. Default:`""`
129+
`auto_merge`|`boolean`| Optional parameter to merge the default branch into the requested deployment branch if necessary. Default:`false`
130+
`description`|`string` | Optional short description. Default:`""`
131+
132+
####Example
133+
134+
<%= json\
135+
:ref => "topic-branch",
136+
:payload => "{\"environment\":\"production\",\"deploy_user\":\"atmos\",\"room_id\":123456}",
137+
:description => "Deploying my sweet branch"
138+
%>
139+
140+
<%= headers 201,
141+
:Location =>
142+
'https://api.github.com/repos/octocat/example/deployments/1' %>
143+
<%= json:deployment %>
144+
145+
##Update a Deployment
146+
147+
Once a deployment is created, it cannot be updated. Information relating to the
148+
success or failure of a deployment is handled through Deployment Statuses.
149+
150+
#Deployment Statuses
151+
152+
##List Deployment Statuses
153+
154+
Users with pull access can view deployment statuses for a deployment:
155+
156+
GET /repos/:owner/:repo/deployments/:id/statuses
157+
158+
###Parameters
159+
160+
Name | Type | Description
161+
-----|------|--------------
162+
`id` |`integer`|**Required**. The Deployment ID to list the statuses from.
163+
164+
165+
###Response
166+
167+
<%= headers 200,:pagination => default_pagination_rels %>
168+
<%= json(:deployment_status) { |h|[h] } %>
169+
170+
##Create a Deployment Status
171+
172+
Users with push access can create deployment statuses for a given deployment:
173+
174+
POST /repos/:owner/:repo/deployments/:id/statuses
175+
176+
###Parameters
177+
178+
Name | Type | Description
179+
-----|------|--------------
180+
`state`|`string` |**Required**. The state of the status. Can be one of`pending`,`success`,`error`, or`failure`.
181+
`target_url`|`string` | 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. Default:`""`
182+
`description`|`string` | A short description of the status. Default:`""`
183+
184+
####Example
185+
186+
<%= json\
187+
:state => "success",
188+
:target_url => "https://example.com/deployment/42/output",
189+
:description => "Deployment finished successfully."
190+
%>
191+
192+
###Response
193+
194+
<%= headers 201,
195+
:Location =>
196+
'https://api.github.com/repos/octocat/example/deployments/42/statuses/1' %>
197+
<%= json:deployment_status %>

‎content/v3/repos/statuses.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Name | Type | Description
6161

6262
<%= json\
6363
:state => "success",
64-
:target_url=> "https://example.com/build/status",
64+
:target_url => "https://example.com/build/status",
6565
:description => "The build succeeded!"
6666
%>
6767

‎layouts/sidebar.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ <h3><a href="#" class="js-expand-btn collapsed arrow-btn"></a><a href="/v3/repos
7979
<li><ahref="/v3/repos/commits/">Commits</a></li>
8080
<li><ahref="/v3/repos/contents/">Contents</a></li>
8181
<li><ahref="/v3/repos/keys/">Deploy Keys</a></li>
82+
<li><ahref="/v3/repos/deployments/">Deployments</a></li>
8283
<li><ahref="/v3/repos/downloads/">Downloads</a></li>
8384
<li><ahref="/v3/repos/forks/">Forks</a></li>
8485
<li><ahref="/v3/repos/hooks/">Hooks</a></li>

‎lib/resources.rb

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ module Helpers
3838
:Caged=>'97c3a8eea9b7eaa9e1e93ea3cd47399f',
3939
:foca=>'d0ca2bf32bda9e9ea8c4473ffc3aaa0d',
4040
:ymendel=>'b1b1d33e0655e841d4fd8467359c58d0',
41-
:mastahyeti=>'8caa0afdae1a934c30a1998472c63134'
41+
:mastahyeti=>'8caa0afdae1a934c30a1998472c63134',
42+
:atmos=>'a86224d72ce21cd9f5bee6784d4b06c7'
4243
}
4344

4445
DefaultTimeFormat="%B %-d, %Y".freeze
@@ -1513,6 +1514,30 @@ def text_html(response, status, head = {})
15131514
},
15141515
]
15151516

1517+
DEPLOYMENT={
1518+
"id"=>1,
1519+
"sha"=>"topic-branch",
1520+
"url"=>"https://api.github.com/repos/octocat/example/deployments/1",
1521+
"creator"=>USER,
1522+
"payload"=>JSON.dump({:environment=>'production'}),
1523+
"created_at"=>"2012-07-20T01:19:13Z",
1524+
"updated_at"=>"2012-07-20T01:19:13Z",
1525+
"description"=>"Deploy request from hubot",
1526+
"statuses_url"=>"https://api.github.com/repos/octocat/example/deployments/1/statuses"
1527+
}
1528+
1529+
DEPLOYMENT_STATUS={
1530+
"id"=>1,
1531+
"url"=>"https://api.github.com/repos/octocat/example/deployments/1/statuses/42",
1532+
"state"=>"success",
1533+
"creator"=>USER,
1534+
"payload"=>JSON.dump({:environment=>'production'}),
1535+
"target_url"=>"https://gist.github.com/628b2736d379f",
1536+
"created_at"=>"2012-07-20T01:19:13Z",
1537+
"updated_at"=>"2012-07-20T01:19:13Z",
1538+
"description"=>"Deploy request from hubot",
1539+
}
1540+
15161541
STATUS={
15171542
"created_at"=>"2012-07-20T01:19:13Z",
15181543
"updated_at"=>"2012-07-20T01:19:13Z",

‎static/search-index.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@
210210
"title":"Contents",
211211
"section":"API/Repositories"
212212
},
213+
{
214+
"url":"/v3/repos/deployments/",
215+
"title":"Deployments",
216+
"section":"API/Repositories"
217+
},
213218
{
214219
"url":"/v3/repos/downloads/",
215220
"title":"Downloads",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp