Skip to content

Commit

Permalink
Merge pull request #40 from StackStorm-Exchange/feature/create-pull
Browse files Browse the repository at this point in the history
Added new github.create_pull action to create pull requests
  • Loading branch information
blag authored Jul 16, 2021
2 parents f6bd4d7 + e28089b commit 30bc3ae
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions actions/create_pull.py
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions actions/create_pull.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion pack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ keywords:
- git
- scm
- serverless
version: 2.0.1
version: 2.1.0
python_versions:
- "3"
author : StackStorm, Inc.
Expand Down

0 comments on commit 30bc3ae

Please sign in to comment.