Skip to content

Commit

Permalink
chore: use different logic for multiple labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol-Baranwal committed Nov 15, 2023
1 parent 13eeefa commit 27b91c1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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");
Expand Down Expand Up @@ -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,
Expand All @@ -88,7 +87,7 @@ async function HandleMultipleIssues() {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumberToLabel,
labels: [label],
labels: [labels],
});
}

Expand Down

0 comments on commit 27b91c1

Please sign in to comment.