Skip to content

Commit

Permalink
chore: fetch the list and comment prev issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol-Baranwal committed Oct 15, 2023
1 parent 6bb9724 commit 37917cf
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,17 @@ async function run() {

core.notice("step 3.");

if (authorIssues.length > 1) {
const previousIssueNumbers = authorIssues
.filter((issue) => issue.number !== context.issue.number) // Exclude the current issue
.map((issue) => issue.number);

if (previousIssueNumbers.length > 0) {
const issueNumberToLabel = context.issue.number;

const issueLinks = previousIssueNumbers
.map((issueNumber) => `#${issueNumber}`)
.join(", ");

// Check if label is an array and add multiple labels if needed
if (Array.isArray(label)) {
for (const lbl of label) {
Expand All @@ -81,15 +89,15 @@ async function run() {

// Add comments based on conditions
if (issueNumber) {
const issueLink = `#${issueNumberToLabel}`;
// const issueLink = `#${issueNumberToLabel}`;
let commentText: string = "";

if (!checkComment) {
// Condition 1: issueNumber is true, comment is false
commentText = `${issueLink} is already opened by you.`;
commentText = `${issueLinks} is already opened by you.`;
} else if (checkComment) {
// Condition 2: issueNumber is true, comment is true
commentText = `${issueLink} ${comment}`;
commentText = `${issueLinks} ${comment}`;
}

await octokit.rest.issues.createComment({
Expand Down

0 comments on commit 37917cf

Please sign in to comment.