diff --git a/CHANGES.md b/CHANGES.md index ac17160..12a36fa 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changelog +## 2.1.0 + +* Add new ``github.create_pull`` action which allows user create Pull Requests for a branch. + ## 2.0.1 * Bug fix (#38) where the sensor assumes `event.id` coming from the GitHub api will be in numeric order. diff --git a/README.md b/README.md index 87f769b..3bb3999 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,7 @@ StackStorm webhook handler. * ``add_status`` - Add commit status to the provided commit. * ``create_file`` - Create new file. * ``create_issue`` - Create a new issue. +* ``create_pull`` - Create a new Pull Request. * ``delete_branch_protection`` - Remove branch protection settings. * ``get_branch_protection`` - Get branch protection settings. * ``get_contents`` - Get repository or file contents. diff --git a/actions/create_pull.py b/actions/create_pull.py new file mode 100644 index 0000000..5274d95 --- /dev/null +++ b/actions/create_pull.py @@ -0,0 +1,15 @@ +from lib.base import BaseGithubAction +from lib.formatters import pull_to_dict + +__all__ = [ + 'CreatePullAction' +] + + +class CreatePullAction(BaseGithubAction): + def run(self, user, repo, title, body, head, base): + user = self._client.get_user(user) + repo = user.get_repo(repo) + pull = repo.create_pull(title=title, body=body, head=head, base=base) + result = pull_to_dict(pull=pull) + return result diff --git a/actions/create_pull.yaml b/actions/create_pull.yaml new file mode 100644 index 0000000..d1caf79 --- /dev/null +++ b/actions/create_pull.yaml @@ -0,0 +1,34 @@ +--- +name: create_pull +runner_type: python-script +description: > + Creates a Github pull request. + Example: + st2 run github.create_pull user=user_or_org repo=myreponame title="test github.create_pull" body="test" head=feature/xyz base=master +enabled: true +entry_point: create_pull.py +parameters: + user: + type: "string" + description: "User / organization name." + required: true + repo: + type: "string" + description: "Repository name." + required: true + title: + type: "string" + description: "Title of the Pull Request" + required: true + body: + type: "string" + description: "The contents of the pull request." + required: true + head: + type: "string" + description: "The name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace head with a user like this: username:branch." + required: true + base: + type: "string" + description: "The name of the branch you want the changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repository that requests a merge to a base of another repository." + required: true diff --git a/pack.yaml b/pack.yaml index b3a88a6..f730436 100644 --- a/pack.yaml +++ b/pack.yaml @@ -8,7 +8,7 @@ keywords: - git - scm - serverless -version: 2.0.1 +version: 2.1.0 python_versions: - "3" author : StackStorm, Inc.