diff --git a/CHANGELOG.md b/CHANGELOG.md index e407269..f1a53e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ 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) + - 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) diff --git a/README.md b/README.md index 2a379fe..90c73ed 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ Unlike standard actions, this action just uses variables from the environment. | PULL_REQUEST_TEAM_REVIEWERS | A list (string with spaces) of teams to assign review | false | unset | | PASS_ON_ERROR | Instead of failing on an error response, pass | unset | | PASS_IF_EXISTS | Instead of failing if the pull request already exists, pass | unset | +| PULL_REQUEST_UPDATE | If the pull request already exists, update it | unset | +| PULL_REQUEST_STATE | If `PULL_REQUEST_UPDATE` is true, update to this state (open, closed) | open | For `PULL_REQUEST_DRAFT`, `PASS_ON_ERROR`, `PASS_IF_EXISTS`, and `MAINTAINER_CANT_MODIFY`, these are treated as environment booleans. If they are defined in the environment, they trigger the @@ -56,6 +58,7 @@ treated as environment booleans. If they are defined in the environment, they tr - Define `PULL_REQUEST_DRAFT` if you want the PR to be a draft. - Define `PASS_ON_ERROR` if you want the PR to not exit given any non 200/201 response. - Define `PASS_IF_EXISTS` if you want the PR to not exit given the pull request is already open. + - Define `PULL_REQUEST_UPDATE` if you want the pull request to be updated if it already exits. For `PULL_REQUEST_ASSIGNEES`, `PULL_REQUEST_REVIEWERS`, and `PULL_REQUEST_TEAM_REVIEWERS` you can provide a string of one or more GitHub usernames (or team names) to diff --git a/pull-request.py b/pull-request.py index 8c6c463..ac352c0 100755 --- a/pull-request.py +++ b/pull-request.py @@ -188,11 +188,12 @@ def list_pull_requests(target, source): return response.json() -def add_assignees(entry): +def add_assignees(entry, assignees): """Given a pull request metadata (from create or update) add assignees Parameters: - entry (dict) : the pull request metadata + entry (dict) : the pull request metadata + assignees (str) : comma separated assignees string set by action """ # Remove leading and trailing quotes assignees = parse_into_list(assignees) @@ -320,7 +321,7 @@ def create_pull_request( # If we have opened or updated, we can add assignees if response and assignees: - add_assignees(response) + add_assignees(response, assignees) if response and (reviewers or team_reviewers): add_reviewers(response, reviewers, team_reviewers)