Skip to content

Commit

Permalink
dist
Browse files Browse the repository at this point in the history
  • Loading branch information
Logerfo committed Nov 11, 2019
1 parent a2fea28 commit 24a00c6
Showing 1 changed file with 36 additions and 18 deletions.
54 changes: 36 additions & 18 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ async function run() {
return;
}
const event = await getEvent();
if (!["opened", "milestoned", "demilestoned", "created", "deleted"].includes(event.action)) {
if (!["opened", "closed", "milestoned", "demilestoned", "created", "deleted"].includes(event.action)) {
core.info("This action is supposed to run for milestone and project changes and issue creation only. Stepping out...");
return;
}
Expand All @@ -437,7 +437,17 @@ async function run() {
core.info("Milestone is disbled. Consider removing the \"milestoned\" and \"demilestoned\" from the trigger types. Stepping out...");
return;
}
await triage(context.payload.issue);
if (event.action == "closed") {
if (context.payload.issue.labels.map(labelMap).includes(label)) {
await removeLabel(context.payload.issue);
}
else {
core.info("Closed label doesn't have triage label. Stepping out...");
}
}
else {
await triage(context.payload.issue);
}
break;

case "project_card":
Expand Down Expand Up @@ -521,30 +531,38 @@ async function triage(issue, knownContained = false) {
const isTriage = milestone && !issue.milestone && project && !(knownContained || await projectContained(issue));
const isLabeled = issue.labels.map(labelMap).includes(label);
if (isTriage && !isLabeled) {
core.info(`Applying "${label}" label...`);
const labelResponse = await client.issues.addLabels({
issue_number: issue.number,
labels: [label],
owner,
repo,
});
core.debug(JSON.stringify(labelResponse.data));
await addLabel(issue);
}
else if (!isTriage && isLabeled) {
core.info(`Removing "${label}" label...`);
const labelResponse = await client.issues.removeLabel({
issue_number: issue.number,
owner,
name: label,
repo,
});
core.debug(JSON.stringify(labelResponse.data));
await removeLabel(issue);
}
else {
core.info("State hasn't changed. Skipping...");
}
}

async function addLabel(issue) {
core.info(`Applying "${label}" label...`);
const labelResponse = await client.issues.addLabels({
issue_number: issue.number,
labels: [label],
owner,
repo,
});
core.debug(JSON.stringify(labelResponse.data));
}

async function removeLabel(issue) {
core.info(`Removing "${label}" label...`);
const labelResponse = await client.issues.removeLabel({
issue_number: issue.number,
owner,
name: label,
repo,
});
core.debug(JSON.stringify(labelResponse.data));
}

run();


Expand Down

0 comments on commit 24a00c6

Please sign in to comment.