diff --git a/README.md b/README.md index 78ac01e..1c5578f 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Create a `workflow.yml` file in your `.github/workflows` directory like: steps: - uses: "actions/checkout@master" - name: "TODO to Issue" - uses: "alstr/todo-to-issue-action@v4.3.1" + uses: "alstr/todo-to-issue-action@v4.4" id: "todo" ``` @@ -51,6 +51,7 @@ The workflow file takes the following optional inputs: | `CLOSE_ISSUES` | No | Optional boolean input that specifies whether to attempt to close an issue when a TODO is removed. Default: `true`. | | `AUTO_P` | No | Optional boolean input that specifies whether to format each line in multiline TODOs as a new paragraph. Default: `true`. | | `IGNORE` | No | Optional string input that provides comma-delimited regular expressions that match files in the repo that we should not scan for TODOs. By default, we will scan all files. | +| `AUTO_ASSIGN` | No | Optional boolean input that specifies whether to assign the newly created issue to the user who triggered the action. If users are manually assigned to an issue, this setting is ignored. Default: `false`. | These can be specified in `with` in the workflow file. diff --git a/action.yml b/action.yml index 3cb5b70..a6cc022 100644 --- a/action.yml +++ b/action.yml @@ -58,3 +58,11 @@ inputs: IGNORE: description: "A collection of comma-delimited regular expression that matches files that should be ignored when searching for TODOs" required: false + AUTO_ASSIGN: + description: "Automatically assign new issues to the user who triggered the action" + required: true + default: false + ACTOR: + description: "The username of the person who triggered the action" + required: true + default: "${{ github.actor }}" \ No newline at end of file diff --git a/main.py b/main.py index 45f9946..c1620a7 100644 --- a/main.py +++ b/main.py @@ -62,6 +62,8 @@ class GitHubClient(object): self.line_break = '\n\n' if auto_p else '\n' # Retrieve the existing repo issues now so we can easily check them later. self._get_existing_issues() + self.auto_assign = os.getenv('INPUT_AUTO_ASSIGN', 'false') == 'true' + self.actor = os.getenv('INPUT_ACTOR') def get_timestamp(self, commit): return commit.get('timestamp') @@ -146,6 +148,8 @@ class GitHubClient(object): # We need to check if any assignees/milestone specified exist, otherwise issue creation will fail. valid_assignees = [] + if len(issue.assignees) == 0 and self.auto_assign: + valid_assignees.append(self.actor) for assignee in issue.assignees: assignee_url = f'{self.repos_url}{self.repo}/assignees/{assignee}' assignee_request = requests.get(url=assignee_url, headers=self.issue_headers)