From 27b91c17cb8a5969ccb7510f7090784658c83835 Mon Sep 17 00:00:00 2001 From: Anmol Baranwal Date: Wed, 15 Nov 2023 22:43:17 +0530 Subject: [PATCH] chore: use different logic for multiple labels --- src/index.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index ad1b734..e043ece 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,8 +2,6 @@ import * as core from "@actions/core"; import * as github from "@actions/github"; async function HandleMultipleIssues() { - console.log("Hello World!"); - try { const token = core.getInput("gh-token"); @@ -24,7 +22,8 @@ async function HandleMultipleIssues() { // Retrieve custom inputs // const label = core.getInput("label") || "multiple issues"; // Set default label - const label = JSON.parse(core.getInput("label")) || ["multiple issues"]; + const labelInput = core.getInput("label"); + const labels = labelInput.split(",").map(label => label.trim()); const assign = core.getInput("assign") === "true" || false; const issueNumber = core.getInput("issueNumber") === "true" || false; // converts to boolean const comment = core.getInput("comment"); @@ -73,8 +72,8 @@ async function HandleMultipleIssues() { .join(", "); // Check if label is an array and add multiple labels if needed - if (Array.isArray(label)) { - for (const lbl of label) { + if (Array.isArray(labels)) { + for (const lbl of labels) { await octokit.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, @@ -88,7 +87,7 @@ async function HandleMultipleIssues() { owner: context.repo.owner, repo: context.repo.repo, issue_number: issueNumberToLabel, - labels: [label], + labels: [labels], }); }