10000 Merge pull request #250 from sigmavirus24/deployment · staticdev/github4.py@b4a2783 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 22, 2021. It is now read-only.

Commit b4a2783

Browse files
committed
Merge pull request sigmavirus24#250 from sigmavirus24/deployment
Deployment
2 parents 45f8a5e + 93434ee commit b4a2783

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

github3/repos/deployment.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
3-
from json import loads
43

54
from github3.models import GitHubCore
65
from github3.users import User
@@ -21,6 +20,10 @@ def __init__(self, deployment, session=None):
2120
#: SHA of the branch on GitHub
2221
self.sha = deployment.get('sha')
2322

23+
#: The reference used to create the Deployment, e.g.,
24+
#: `deploy-20140526`
25+
self.ref = deployment.get('ref')
26+
2427
#: User object representing the creator of the deployment
2528
self.creator = deployment.get('creator')
2629
if self.creator:
@@ -38,6 +41,9 @@ def __init__(self, deployment, session=None):
3841
#: Description of the deployment
3942
self.description = deployment.get('description')
4043

44+
#: Target for the deployment, e.g., 'production', 'staging'
45+
self.environment = deployment.get('environment')
46+
4147
#: URL to get the statuses of this deployment
4248
self.statuses_url = deployment.get('statuses_url')
4349

@@ -113,5 +119,14 @@ def __init__(self, status, session=None):
113119
#: Description of the deployment
114120
self.description = status.get('description')
115121

122+
#: :class:`Deployment` representing the deployment this status is
123+
#: associated with
124+
self.deployment = status.get('deployment')
125+
if self.deployment:
126+
self.deployment = Deployment(self.deployment, self)
127+
128+
#: URL for the deployment this status is associated with
129+
self.deployment_url = status.get('deployment_url')
130+
116131
def _repr(self):
117132
return '<DeploymentStatus [{0}]>'.format(self.id)

github3/repos/repo.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ def create_commit(self, message, tree, parents, author={}, committer={}):
504504

505505
@requires_auth
506506
def create_deployment(self, ref, force=False, payload='',
507-
auto_merge=False, description=''):
507+
auto_merge=False, description='', environment=None):
508508
"""Create a deployment.
509509
510510
:param str ref: (required), The ref to deploy. This can be a branch,
@@ -516,13 +516,17 @@ def create_deployment(self, ref, force=False, payload='',
516516
:param bool auto_merge: Optional parameter to merge the default branch
517517
into the requested deployment branch if necessary. Default: False
518518
:param str description: Optional short description. Default: ""
519+
:param str environment: Optional name for the target deployment
520+
environment (e.g., production, staging, qa). Default: "production"
519521
:returns: :class:`Deployment <github3.repos.deployment.Deployment>`
520522
"""
521523
json = None
522524
if ref:
523525
url = self._build_url('deployments', base_url=self._api)
524526
data = {'ref': ref, 'force': force, 'payload': payload,
525-
'auto_merge': auto_merge, 'description': description}
527+
'auto_merge': auto_merge, 'description': description,
528+
'environment': environment}
529+
self._remove_none(data)
526530
headers = Deployment.CUSTOM_HEADERS
527531
json = self._json(self._post(url, data=data, headers=headers),
528532
201)

0 commit comments

Comments
 (0)
0