Skip to content

Commit 06bf42c

Browse files
adrianmoiseysigmavirus24
authored andcommitted
Update create_deployment() to match current API
Update create_deployment() according to https://developer.github.com/v3/repos/deployments/#create-a-deployment
1 parent 73296ad commit 06bf42c

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

github3/repos/repo.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -687,14 +687,15 @@ def create_commit(self, message, tree, parents, author=None,
687687
return self._instance_or_null(Commit, json)
688688

689689
@requires_auth
690-
def create_deployment(self, ref, force=False, payload='',
690+
def create_deployment(self, ref, required_contexts=None, payload='',
691691
auto_merge=False, description='', environment=None):
692692
"""Create a deployment.
693693
694694
:param str ref: (required), The ref to deploy. This can be a branch,
695695
tag, or sha.
696-
:param bool force: Optional parameter to bypass any ahead/behind
697-
checks or commit status checks. Default: False
696+
:param list required_contexts: Optional array of status contexts
697+
verified against commit status checks. To bypass checking
698+
entirely pass an empty array. Default: []
698699
:param str payload: Optional JSON payload with extra information about
699700
the deployment. Default: ""
700701
:param bool auto_merge: Optional parameter to merge the default branch
@@ -706,10 +707,12 @@ def create_deployment(self, ref, force=False, payload='',
706707
"""
707708
json = None
708709
if ref:
710+
if required_contexts is None:
711+
required_contexts = []
709712
url = self._build_url('deployments', base_url=self._api)
710-
data = {'ref': ref, 'force': force, 'payload': payload,
711-
'auto_merge': auto_merge, 'description': description,
712-
'environment': environment}
713+
data = {'ref': ref, 'required_contexts': required_contexts,
714+
'payload': payload, 'auto_merge': auto_merge,
715+
'description': description, 'environment': environment}
713716
self._remove_none(data)
714717
json = self._json(self._post(url, data=data),
715718
201)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"http_interactions": [{"request": {"body": "", "headers": {"Accept-Encoding": "gzip, deflate, compress", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/0.8.0", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "method": "GET", "uri": "https://api.github.com/repos/sigmavir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NzFFszWazJhO8LasLoR0zuCMAxXWSoWp00dkMDFQ9Bbdttb4jmSmq91zx1CndzhAAu2100doRxjFWoQV2EtgCxsRC5sJYVbqdsRfKmF0qK3cyeUvHcj/drkDNFyPLREx5nk8RteiyJeIYtTbtIgpO4eahjoBl4AaCiFrkAiHt5PWB0bCu00y0QCOSbrlFAxHM/eBpHj754Xd/vVmsNovwL8xbV+nVmOhpHjwF4fdgvvGDTRjRmKo22QhzMySgITgB+xDEJ7rd+Pf+ftRS0K0BDI3JLoa/XMw2/3H10pslOWLpJujfPufh9rX02BRSM1WICmVCf4lzXmVYnWbwdIr2K1WJmaEHZrQy+QNDF6vV8qogSFRdYj/8Z1w/HblF7YpX7/jhUEicmz6ampttl6bexuqauko8uRwDo4dH+SLPHV/XtPX0aI1TUmqt+quoEkmKfr8SZc8+ywi7xtF4G7IZjYBu/DbI7leRih2vc7vtimfITlH156qiyBG6gG66mKC7sr5T7lZAUTWshs6L7jMa6FLYI3rFQQ1JGJcpg6+i138A/TI3gs0TAAA=", "encoding": "utf-8"}, "headers": {"status": "200 OK", "x-ratelimit-remaining": "4997", "x-github-media-type": "github.v3; param=full; format=json", "x-content-type-options": "nosniff", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "transfer-encoding": "chunked", "x-github-request-id": "48A0D539:60AD:2582B20:530AACF3", "content-encoding": "gzip", "vary": "Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding", "server": "GitHub.com", "cache-control": "private, max-age=60, s-maxage=60", "last-modified": "Sun, 23 Feb 2014 20:12:34 GMT", "x-ratelimit-limit": "5000", "etag": "\"428a90e7f7aac36394a2dbf5dc9e14ab\"", "access-control-allow-credentials": "true", "date": "Mon, 24 Feb 2014 02:22:44 GMT", "access-control-allow-origin": "*", "content-type": "application/json; charset=utf-8", "x-ratelimit-reset": "1393211460"}, "url": "https://api.github.com/repos/sigmavirus24/github3.py", "status_code": 200}, "recorded_at": "2014-02-24T02:21:07"}, {"request": {"body": "{\"force\": false, \"ref\": \"0.8.2\", \"payload\": \"\", \"auto_merge\": false, \"description\": \"\"}", "headers": {"Content-Length": "87", "Accept-Encoding": "gzip, deflate, compress", "Accept": "application/vnd.github.cannonball-preview+json", "User-Agent": "github3.py/0.8.0", "Accept-Charset": "utf-8", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "method": "POST", "uri": "https://api.github.com/repos/sigmavirus24/github3.py/deployments"}, "response": {"body": {"string": "{\"url\":\"https://api.github.com/repos/sigmavirus24/github3.py/deployments/801\",\"id\":801,\"sha\":\"aa0b457c3c7692a0da05b6771ce44c980febd4a1\",\"payload\":\"\\\"\\\"\",\"description\":\"\",\"creator\":{\"login\":\"sigmavirus24\",\"id\":240830,\"avatar_url\":\"https://gravatar.com/avatar/c148356d89f925e692178bee1d93acf7?d=https%3A%2F%2Fidenticons.github.com%2F4a71764034cdae877484be72718ba526.png&r=x\",\"gravatar_id\":\"c148356d89f925e692178bee1d93acf7\",\"url\":\"https://api.github.com/users/sigmavirus24\",\"html_url\":\"https://github.com/sigmavirus24\",\"followers_url\":\"https://api.github.com/users/sigmavirus24/followers\",\"following_url\":\"https://api.github.com/users/sigmavirus24/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/sigmavirus24/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/sigmavirus24/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/sigmavirus24/subscriptions\",\"organizations_url\":\"https://api.github.com/users/sigmavirus24/orgs\",\"repos_url\":\"https://api.github.com/users/sigmavirus24/repos\",\"events_url\":\"https://api.github.com/users/sigmavirus24/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/sigmavirus24/received_events\",\"type\":\"User\",\"site_admin\":false},\"created_at\":\"2014-02-24T02:22:44Z\",\"updated_at\":\"2014-02-24T02:22:44Z\",\"statuses_url\":\"https://api.github.com/repos/sigmavirus24/github3.py/deployments/801/statuses\"}", "encoding": "utf-8"}, "headers": {"status": "201 Created", "x-ratelimit-remaining": "4996", "x-github-media-type": "github.cannonball-preview; format=json", "x-content-type-options": "nosniff", "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "x-github-request-id": "48A0D539:60AD:2582B48:530AACF4", "cache-control": "private, max-age=60, s-maxage=60", "vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "content-length": "1389", "server": "GitHub.com", "last-modified": "Mon, 24 Feb 2014 02:22:44 GMT", "x-ratelimit-limit": "5000", "location": "https://api.github.com/repos/sigmavirus24/github3.py/deployments/801", "access-control-allow-credentials": "true", "date": "Mon, 24 Feb 2014 02:22:44 GMT", "etag": "\"17579795205f3c31a17f64dbfff32052\"", "content-type": "application/json; charset=utf-8", "access-control-allow-origin": "*", "x-ratelimit-reset": "1393211460"}, "url": "https://api.github.com/repos/sigmavirus24/github3.py/deployments", "status_code": 201}, "recorded_at": "2014-02-24T02:21:07"}], "recorded_with": "betamax"}
1+
{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.drax-preview+json", "User-Agent": "github3.py/1.0.0a4", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "method": "GET", "uri": "https://api.github.com/repos/adrianmoisey/temptest"}, "response": {"body": {"string": "", "base64_string": "H4sIAAAAAAAAA6WYy3LqOBCG38XbAcQlJ5m4auqcRziLzGY2lLAFVsWWXJIMRVx59/lbsrGhZrhpk4BRf/rV6pa71SYyT9KXt9VysfjxNkkUr0SSJk5UtRPWJZNk25TlunvMcyO5qrS04shGY/RBCZOkbVLqnVSwHw8Eg+Z4W72ulu+ThO+542bdmBLjCudq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lC64m08POqrCuB+H12hFU3B7Trkc5I601AriCfDaTF6eJCfcjyIlNlTtxdatmGyShqju0sdhfxG014L1c3Vi1rRJQj1aqR49HuS4pd+Bf7HXGx5U7p1KKOxgopb59vbWpgKK6B7Bbpv6hrdsBaKn14yHTLhM/rfUmZCWfgvSFPCHaBj5KtxPdMtavH9L5gzy3cbEwAA", "encoding": "utf-8"}, "headers": {"X-XSS-Protection": "1; mode=block", "Content-Security-Policy": "default-src 'none'", "Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "Transfer-Encoding": "chunked", "Last-Modified": "Fri, 24 Jun 2016 08:06:09 GMT", "Access-Control-Allow-Origin": "*", "X-Frame-Options": "deny", "Status": "200 OK", "X-Served-By": "88531cdcf1929112ec480e1806d44a33", "X-GitHub-Request-Id": "29474346:4452:7C678FA:57FC7480", "ETag": "W/\"ec5b8b5170d185a3ba41f28cd029eedd\"", "Date": "Tue, 11 Oct 2016 05:11:28 GMT", "X-RateLimit-Remaining": "4957", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "Server": "GitHub.com", "X-GitHub-Media-Type": "github.drax-preview; format=json", "X-Content-Type-Options": "nosniff", "Content-Encoding": "gzip", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "X-RateLimit-Limit": "5000", "Cache-Control": "private, max-age=60, s-maxage=60", "Content-Type": "application/json; charset=utf-8", "X-RateLimit-Reset": "1476164306"}, "status": {"message": "OK", "code": 200}, "url": "https://api.github.com/repos/adrianmoisey/temptest"}, "recorded_at": "2016-10-11T05:11:28"}, {"request": {"body": {"string": "{\"description\": \"\", \"auto_merge\": false, \"required_contexts\": [], \"ref\": \"adrianmoisey-patch-1\", \"payload\": \"\"}", "encoding": "utf-8"}, "headers": {"Content-Length": "111", "Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a4", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json", "Authorization": "Basic <BASIC_AUTH>"}, "method": "POST", "uri": "https://api.github.com/repos/adrianmoisey/temptest/deployments"}, "response": {"body": {"string": "{\"url\":\"https://api.github.com/repos/adrianmoisey/temptest/deployments/14050857\",\"id\":14050857,\"sha\":\"e03bfa426187a492dffd295aae9310c3cf0ac02d\",\"ref\":\"adrianmoisey-patch-1\",\"task\":\"deploy\",\"payload\":\"\",\"environment\":\"production\",\"description\":\"\",\"creator\":{\"login\":\"adrianmoisey\",\"id\":736329,\"avatar_url\":\"https://avatars.githubusercontent.com/u/736329?v=3\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/adrianmoisey\",\"html_url\":\"https://github.com/adrianmoisey\",\"followers_url\":\"https://api.github.com/users/adrianmoisey/followers\",\"following_url\":\"https://api.github.com/users/adrianmoisey/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/adrianmoisey/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/adrianmoisey/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/adrianmoisey/subscriptions\",\"organizations_url\":\"https://api.github.com/users/adrianmoisey/orgs\",\"repos_url\":\"https://api.github.com/users/adrianmoisey/repos\",\"events_url\":\"https://api.github.com/users/adrianmoisey/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/adrianmoisey/received_events\",\"type\":\"User\",\"site_admin\":false},\"created_at\":\"2016-10-11T05:11:29Z\",\"updated_at\":\"2016-10-11T05:11:29Z\",\"statuses_url\":\"https://api.github.com/repos/adrianmoisey/temptest/deployments/14050857/statuses\",\"repository_url\":\"https://api.github.com/repos/adrianmoisey/temptest\"}", "encoding": "utf-8"}, "headers": {"Content-Length": "1415", "X-XSS-Protection": "1; mode=block", "Content-Security-Policy": "default-src 'none'", "Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", "Last-Modified": "Tue, 11 Oct 2016 05:11:29 GMT", "Location": "https://api.github.com/repos/adrianmoisey/temptest/deployments/14050857", "Access-Control-Allow-Origin": "*", "X-Frame-Options": "deny", "Status": "201 Created", "X-Served-By": "0e17b94a265a427d9cafe798ceea7c02", "X-GitHub-Request-Id": "29474346:4452:7C67930:57FC7480", "ETag": "\"a6763b0f146a657e7c6bba6bc115890c\"", "Date": "Tue, 11 Oct 2016 05:11:29 GMT", "X-RateLimit-Remaining": "4956", "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", "Server": "GitHub.com", "X-GitHub-Media-Type": "github.v3; param=full; format=json", "X-Content-Type-Options": "nosniff", "Vary": "Accept, Authorization, Cookie, X-GitHub-OTP", "X-RateLimit-Limit": "5000", "Cache-Control": "private, max-age=60, s-maxage=60", "Content-Type": "application/json; charset=utf-8", "X-RateLimit-Reset": "1476164306"}, "status": {"message": "Created", "code": 201}, "url": "https://api.github.com/repos/adrianmoisey/temptest/deployments"}, "recorded_at": "2016-10-11T05:11:28"}], "recorded_with": "betamax/0.8.0"}

tests/integration/test_repos_repo.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ def test_create_deployment(self):
231231
self.basic_login()
232232
cassette_name = self.cassette_name('create_deployment')
233233
with self.recorder.use_cassette(cassette_name):
234-
repository = self.gh.repository('sigmavirus24', 'github3.py')
234+
repository = self.gh.repository('adrianmoisey', 'temptest')
235235
assert repository is not None
236-
deployment = repository.create_deployment('0.8.2')
236+
deployment = repository.create_deployment('adrianmoisey-patch-1')
237237

238238
assert isinstance(deployment, github3.repos.deployment.Deployment)
239239

0 commit comments

Comments
 (0)