From c7789e046e684d2e2d5c0422f862d8ce2250b0b3 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 28 Jan 2025 12:48:45 -0800 Subject: [PATCH] feat: adding default labels to issues --- GitHubClient.py | 9 +++++++++ README.md | 4 ++++ action.yml | 3 +++ 3 files changed, 16 insertions(+) diff --git a/GitHubClient.py b/GitHubClient.py index 7800660..a0cd075 100644 --- a/GitHubClient.py +++ b/GitHubClient.py @@ -268,6 +268,7 @@ class GitHubClient(Client): snippet = '```' + issue.markdown_language + '\n' + issue.hunk + '\n' + '```' issue_template = os.getenv('INPUT_ISSUE_TEMPLATE', None) + default_labels = os.getenv('INPUT_DEFAULT_LABELS', None) if issue_template: issue_contents = (issue_template.replace('{{ title }}', issue.title) .replace('{{ body }}', formatted_issue_body) @@ -286,6 +287,14 @@ class GitHubClient(Client): title = issue.title + if default_labels: + # Ensure default_labels is treated as a list (in case it's a string from the environment variable) + if isinstance(default_labels, str): + default_labels = [label.strip() for label in default_labels.split(',') if label.strip()] + + # Combine default labels with any existing labels, avoiding duplicates + issue.labels = list(set(issue.labels + default_labels)) + if issue.ref: if issue.ref.startswith('@'): # Ref = assignee. diff --git a/README.md b/README.md index a54bcde..52af6c9 100644 --- a/README.md +++ b/README.md @@ -400,6 +400,10 @@ placeholders: If not specified the standard template is used, containing the issue body (if a multiline TODO), URL and snippet. +##### DEFAULT_LABELS + +Custom labels that can be automatically appended to newly created issues, in a form of comma-delimited strings. + #### LANGUAGES A collection of comma-delimited URLs or local paths (starting from the current working directory of the action) diff --git a/action.yml b/action.yml index 50ac2de..636c5c3 100644 --- a/action.yml +++ b/action.yml @@ -60,6 +60,9 @@ inputs: ISSUE_TEMPLATE: description: 'The template used to format new issues' required: false + DEFAULT_LABELS: + description: 'Default labels to be used when add new issues' + required: false IDENTIFIERS: description: 'Dictionary of custom identifiers' required: false