Skip to content

Commit

Permalink
chore: update build
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol-Baranwal committed Nov 15, 2023
1 parent 3153deb commit 479366b
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const core = __importStar(__nccwpck_require__(2186));
const github = __importStar(__nccwpck_require__(5438));
async function HandleMultipleIssues() {
var _a;
console.log("Hello World!");
try {
const token = core.getInput("gh-token");
if (!token)
Expand All @@ -49,8 +48,10 @@ async function HandleMultipleIssues() {
const context = github.context;
core.notice("step 1.");
// Retrieve custom inputs
const label = core.getInput("label") || "multiple issues"; // Set default label
// const label = core.getInput("label") || "multiple issues"; // Set default label
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");
const close = core.getInput("close") === "true" || false;
Expand All @@ -64,12 +65,15 @@ async function HandleMultipleIssues() {
creator: author,
state: "open",
});
if (authorIssues.length === 0) {
core.notice("No existing open issues for this author.");
const filteredIssues = assign
? authorIssues.filter((issue) => issue.assignees.some((assignee) => assignee.login === author))
: authorIssues;
if (filteredIssues.length === 0) {
core.notice(`No existing ${assign === true ? "issues created and assigned to" : "open issues for"} this author.`);
return; // No need to continue.
}
core.notice("step 3.");
const previousIssueNumbers = authorIssues
const previousIssueNumbers = filteredIssues
.filter((issue) => issue.number !== context.issue.number) // Exclude the current issue
.map((issue) => issue.number);
if (previousIssueNumbers.length > 0) {
Expand All @@ -78,8 +82,8 @@ async function HandleMultipleIssues() {
.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) {
if (Array.isArray(labels)) {
for (const lbl of labels) {
await octokit.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -94,7 +98,7 @@ async function HandleMultipleIssues() {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumberToLabel,
labels: [label],
labels: [labels],
});
}
core.notice("Labels added to issue #" + issueNumberToLabel);
Expand All @@ -104,7 +108,10 @@ async function HandleMultipleIssues() {
let commentText = "";
if (!checkComment) {
// Condition 1: issueNumber is true, comment is false
commentText = `${issueLinks} is already opened by you.`;
if (assign)
commentText = `${issueLinks} has been opened by you and is also assigned to you.`;
else
commentText = `${issueLinks} is already opened by you.`;
}
else if (checkComment) {
// Condition 2: issueNumber is true, comment is true
Expand Down

0 comments on commit 479366b

Please sign in to comment.