Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
882391869b | ||
|
|
8f0f9ee92b | ||
|
|
0969c26295 | ||
|
|
d2ea9c206b | ||
|
|
81b48d94ab | ||
|
|
f9e7f419d6 | ||
|
|
dcba08c9c2 | ||
|
|
c8e84cea4c |
16
CHANGELOG.md
16
CHANGELOG.md
@@ -14,10 +14,12 @@ represented by the pull requests that fixed them. Critical items to know are:
|
||||
Versions correspond with GitHub releases that can be referenced with @ using actions.
|
||||
|
||||
## [master](https://github.com/vsoch/pull-request-action/tree/master) (master)
|
||||
- bugfix of token handling if 401 error received (missing 401 case) (1.0.21)
|
||||
- bugfix of writing to environment file (missing newline) (1.0.19)
|
||||
- bugfix of missing from branch with scheduled run (1.0.16)
|
||||
- forgot to add assignees (1.0.15)
|
||||
- output and environment variables for PR number and return codes (1.0.5)
|
||||
- added support for reviewer (individual and team) assignments (1.0.4)
|
||||
- added support for maintainer can modify and assignees (1.0.3)
|
||||
- alpine cannot install to system python anymore (1.1.0)
|
||||
- bugfix of missing output values (1.0.23)
|
||||
- bugfix of token handling if 401 error received (missing 401 case) (1.0.21)
|
||||
- bugfix of writing to environment file (missing newline) (1.0.19)
|
||||
- bugfix of missing from branch with scheduled run (1.0.16)
|
||||
- forgot to add assignees (1.0.15)
|
||||
- output and environment variables for PR number and return codes (1.0.5)
|
||||
- added support for reviewer (individual and team) assignments (1.0.4)
|
||||
- added support for maintainer can modify and assignees (1.0.3)
|
||||
|
||||
@@ -7,9 +7,11 @@ LABEL "com.github.actions.description"="Create a pull request when a branch is c
|
||||
LABEL "com.github.actions.icon"="activity"
|
||||
LABEL "com.github.actions.color"="yellow"
|
||||
|
||||
RUN apk --no-cache add python3 py3-pip git bash && \
|
||||
pip3 install requests
|
||||
# Newer alpine we are not allowed to install to system python
|
||||
RUN apk --no-cache add python3 py3-pip py3-virtualenv git bash && \
|
||||
python3 -m venv /opt/env && \
|
||||
/opt/env/bin/pip3 install requests
|
||||
COPY pull-request.py /pull-request.py
|
||||
|
||||
RUN chmod u+x /pull-request.py
|
||||
ENTRYPOINT ["python3", "/pull-request.py"]
|
||||
ENTRYPOINT ["/opt/env/bin/python3", "/pull-request.py"]
|
||||
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-2023 Vanessa Sochat
|
||||
|
||||
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.
|
||||
@@ -69,17 +69,22 @@ def parse_into_list(values):
|
||||
return [x.strip() for x in values.split(" ")]
|
||||
|
||||
|
||||
def set_env(name, value):
|
||||
def set_env_and_output(name, value):
|
||||
"""helper function to echo a key/value pair to the environement file
|
||||
|
||||
Parameters:
|
||||
name (str) : the name of the environment variable
|
||||
value (str) : the value to write to file
|
||||
"""
|
||||
environment_file_path = os.environ.get("GITHUB_ENV")
|
||||
for env_var in ("GITHUB_ENV", "GITHUB_OUTPUT"):
|
||||
environment_file_path = os.environ.get(env_var)
|
||||
if not environment_file_path:
|
||||
print(f"Warning: {env_var} is unset, skipping.")
|
||||
continue
|
||||
print("Writing %s=%s to %s" % (name, value, env_var))
|
||||
|
||||
with open(environment_file_path, "a") as environment_file:
|
||||
environment_file.write("%s=%s\n" % (name, value))
|
||||
with open(environment_file_path, "a") as environment_file:
|
||||
environment_file.write("%s=%s\n" % (name, value))
|
||||
|
||||
|
||||
def open_pull_request(title, body, target, source, is_draft=False, can_modify=True):
|
||||
@@ -159,12 +164,9 @@ def set_pull_request_groups(response):
|
||||
number = response.get("number")
|
||||
html_url = response.get("html_url")
|
||||
print("Number opened for PR is %s" % number)
|
||||
set_env("PULL_REQUEST_NUMBER", number)
|
||||
print("pull_request_number=%s >> $GITHUB_OUTPUT" % number)
|
||||
set_env("PULL_REQUEST_RETURN_CODE", pull_request_return_code)
|
||||
print("pull_request_return_code=%s >> $GITHUB_OUTPUT" % pull_request_return_code)
|
||||
set_env("PULL_REQUEST_URL", html_url)
|
||||
print("pull_request_url=%s >> $GITHUB_OUTPUT" % html_url)
|
||||
set_env_and_output("PULL_REQUEST_NUMBER", number)
|
||||
set_env_and_output("PULL_REQUEST_RETURN_CODE", pull_request_return_code)
|
||||
set_env_and_output("PULL_REQUEST_URL", html_url)
|
||||
|
||||
|
||||
def list_pull_requests(target, source):
|
||||
@@ -215,8 +217,7 @@ def add_assignees(entry, assignees):
|
||||
print("::group::github assignees response")
|
||||
print(response.json())
|
||||
print("::endgroup::github assignees response")
|
||||
set_env("ASSIGNEES_RETURN_CODE", assignees_return_code)
|
||||
print("assignees_return_code=%s >> $GITHUB_OUTPUT" % assignees_return_code)
|
||||
set_env_and_output("ASSIGNEES_RETURN_CODE", assignees_return_code)
|
||||
|
||||
|
||||
def find_pull_request(listing, source):
|
||||
@@ -272,9 +273,7 @@ def add_reviewers(entry, reviewers, team_reviewers):
|
||||
print("::group::github reviewers response")
|
||||
print(response.json())
|
||||
print("::endgroup::github reviewers response")
|
||||
set_env("REVIEWERS_RETURN_CODE", reviewers_return_code)
|
||||
print("reviewers_return_code=%s >> $GITHUB_OUTPUT" % reviewers_return_code)
|
||||
print("Add reviewers return code: %s" % reviewers_return_code)
|
||||
set_env_and_output("REVIEWERS_RETURN_CODE", reviewers_return_code)
|
||||
|
||||
|
||||
################################################################################
|
||||
@@ -361,7 +360,10 @@ def main():
|
||||
print("No branch prefix is set, all branches will be used.")
|
||||
|
||||
# Default to project default branch if none provided
|
||||
pull_request_branch = os.environ.get("PULL_REQUEST_BRANCH", find_default_branch())
|
||||
pull_request_branch = os.environ.get("PULL_REQUEST_BRANCH")
|
||||
if not pull_request_branch:
|
||||
pull_request_branch = find_default_branch()
|
||||
|
||||
print("Pull requests will go to %s" % pull_request_branch)
|
||||
|
||||
# Pull request draft
|
||||
|
||||
Reference in New Issue
Block a user