forked from dz0ny/create-pr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d6ec7a7
Showing
15 changed files
with
804 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
.pytest_cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.7.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"python.linting.pylintEnabled": false, | ||
"python.linting.flake8Enabled": true, | ||
"python.linting.enabled": true, | ||
"python.pythonPath": "/home/dz0ny/.local/share/virtualenvs/make-pr-9Hm3Atzw/bin/python", | ||
"python.formatting.provider": "black", | ||
"python.unitTest.pyTestArgs": [ | ||
"." | ||
], | ||
"python.unitTest.unittestEnabled": false, | ||
"python.unitTest.nosetestsEnabled": false, | ||
"python.unitTest.pyTestEnabled": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM python:3.7.2-alpine3.9 | ||
|
||
LABEL version="1.0.0" | ||
LABEL repository="http://github.com/dz0ny/make-pr" | ||
LABEL homepage="http://github.com/dz0ny/make-pr" | ||
LABEL maintainer="Janez Troha" | ||
LABEL "com.github.actions.name"="Automatic PR" | ||
LABEL "com.github.actions.description"="Automatically creates PR" | ||
LABEL "com.github.actions.icon"="git-pull-request" | ||
LABEL "com.github.actions.color"="purple" | ||
|
||
RUN apk --no-cache add jq bash | ||
ADD requirements.txt /requirements.txt | ||
RUN pip install -r /requirements.txt && rm -f /requirements.txt | ||
|
||
ADD main.py /main.py | ||
ADD entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Janez Troha | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
flake8 = "*" | ||
black = "==18.9b0" | ||
pytest = "*" | ||
|
||
[packages] | ||
requests = "*" | ||
dacite = "*" | ||
|
||
[requires] | ||
python_version = "3.7" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# GitHub action to automatically create PRs | ||
|
||
## Installation | ||
|
||
To configure the action simply add the following lines to your `.github/main.workflow` workflow file: | ||
|
||
``` | ||
workflow "Automatic PR" { | ||
on = "release" | ||
resolves = "Create PR" | ||
} | ||
action "Create PR" { | ||
uses = "dz0ny/create-pr:master" | ||
args = "path/to/my/patch_recipe.py" | ||
secrets = ["GITHUB_TOKEN"] | ||
} | ||
``` | ||
|
||
Contents of `path/to/my/patch_recipe.py: | ||
|
||
```python | ||
if __name__ == "__main__": | ||
event = Event.fromPath(env["GITHUB_EVENT_PATH"]) | ||
if not event.is_release: | ||
raise Exception("This event is not from release") | ||
|
||
with commit(event, f"update_{event.release.tag_name}") as gh: | ||
versions = gh.get("bin/runtime/versions") | ||
versions.text: str = versions.text.replace("foo.bar", "def.bar") | ||
gh.add(versions, "Update image to latest version") | ||
gh.create_pr( | ||
"Update image to latest version", | ||
"This updates web image to the latest released version", | ||
) | ||
``` | ||
|
||
check api in [main.py](main.py). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Ensure that the GITHUB_TOKEN secret is included | ||
if [[ -z "$GITHUB_TOKEN" ]]; then | ||
echo "Set the GITHUB_TOKEN env variable." | ||
exit 1 | ||
fi | ||
|
||
# Ensure that the file path is present | ||
if [[ -z "$1" ]]; then | ||
echo "You must pass at least one argument to this action, the path to the patching recepie." | ||
exit 1 | ||
fi | ||
echo "Appending patch file $1 to main" | ||
cat $1 >> /main.py | ||
echo "Run patch file in main" | ||
python /main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"type": "file", | ||
"encoding": "base64", | ||
"size": 5362, | ||
"name": "README.md", | ||
"path": "README.md", | ||
"content": "bXkgdXBkYXRlZCBmaWxlIGNvbnRlbnRz", | ||
"sha": "3d21ec53a331a6f037a91c368710b99387d012c1", | ||
"url": "https://api.github.com/repos/octokit/octokit.rb/contents/README.md", | ||
"git_url": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1", | ||
"html_url": "https://github.com/octokit/octokit.rb/blob/master/README.md", | ||
"download_url": "https://raw.githubusercontent.com/octokit/octokit.rb/master/README.md", | ||
"_links": { | ||
"git": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/3d21ec53a331a6f037a91c368710b99387d012c1", | ||
"self": "https://api.github.com/repos/octokit/octokit.rb/contents/README.md", | ||
"html": "https://github.com/octokit/octokit.rb/blob/master/README.md" | ||
} | ||
} |
Oops, something went wrong.