Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add closeSkipLabels for skip closing issue #5

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ GitHub action that deals with stale issues in your project.

- `staleLabel` *string*, a label to be set to the stale issue, __default__: `STALE`
- `staleComment` *string*, a comment placed when marking issue as stale. See a [guide on how to style this message](#styling-close-comment).
- `closeSkipLabels` *string*, comma separated list of labels for skip closing the issue
- `closeComment` *string*, a comment placed when closing issue. See a [guide on how to style this message](#styling-close-comment).

- `showLogs` *bool*. Show logs with info like total number of issues found, stale issues, closed etc. __default__: `true`
Expand All @@ -44,6 +45,7 @@ jobs:
closeAfter: 60
staleLabel: "STALE 📺"
staleComment: "This issue is %DAYS_OLD% days old, marking as stale! cc: @%AUTHOR%"
closeSkipLabels: "priority/P0,priority/P1"
closeComment: "Issue last updated %DAYS_OLD% days ago! Closing down!"
showLogs: true
```
Expand Down
8 changes: 7 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Issue triage'
name: 'Issue triage customized'
description: "Deals with stale issues in your project."
author: "krizzu"
inputs:
Expand All @@ -17,9 +17,15 @@ inputs:
description: label to be set to the stale issue
required: false
default: "STALE 📺"
actionSkipLabels:
description: list of labels to do nothing
required: false
staleComment:
description: a template comment to be placed when handling the issue
required: false
closeSkipLabels:
description: list of labels for skip closing the issue
required: false
closeComment:
description: a template comment to be placed when closing the issue
required: false
Expand Down
32 changes: 30 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4611,9 +4611,33 @@ class ActionIssueTriage {
try {
let isClosingDown = false;

let hasActionSkipLabel = false;
if (this.opts.actionSkipLabels) {
for (const label of issue.labels.map((i) => i.name)) {
if (this.opts.actionSkipLabels.split(',').indexOf(label) > 0) {
hasActionSkipLabel = true;
}
}
}

if (hasActionSkipLabel) {
continue;
}

let hasCloseSkipLabel = false;
if (this.opts.closeSkipLabels) {
for (const label of issue.labels.map((i) => i.name)) {
if (this.opts.closeSkipLabels.split(',').indexOf(label) > 0) {
hasCloseSkipLabel = true;
}
}
}


if (
this.opts.closeAfter > this.opts.staleAfter &&
this._isOlderThan(issue.updated_at, this.opts.closeAfter)
this._isOlderThan(issue.updated_at, this.opts.closeAfter) &&
!hasCloseSkipLabel
) {
isClosingDown = true;
}
Expand Down Expand Up @@ -7743,8 +7767,10 @@ const closeCommentDefault = `🤖 Beep Boop 🤖 \n\nThis issue was inactive for
const staleAfter = core.getInput('staleAfter') || 30;
const closeAfter = core.getInput('closeAfter') || 0;
const staleComment = core.getInput('staleComment') || staleCommentDefault;
const closeComment = core.getInput('staleComment') || closeCommentDefault;
const closeComment = core.getInput('closeComment') || closeCommentDefault;
const staleLabel = core.getInput('staleLabel') || 'STALE';
const actionSkipLabels = core.getInput('actionSkipLabels') || '';
const closeSkipLabels = core.getInput('closeSkipLabels') || '';
const showLogs = core.getInput('showLogs') || 'true';

const GH_TOKEN = core.getInput('ghToken', {
Expand All @@ -7757,8 +7783,10 @@ const options = {
staleAfter: +staleAfter,
closeAfter: +closeAfter,
staleComment,
closeSkipLabels,
closeComment,
staleLabel,
actionSkipLabels,
showLogs: showLogs === 'true',
};

Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ const closeCommentDefault = `🤖 Beep Boop 🤖 \n\nThis issue was inactive for
const staleAfter = core.getInput('staleAfter') || 30;
const closeAfter = core.getInput('closeAfter') || 0;
const staleComment = core.getInput('staleComment') || staleCommentDefault;
const closeComment = core.getInput('staleComment') || closeCommentDefault;
const closeComment = core.getInput('closeComment') || closeCommentDefault;
const staleLabel = core.getInput('staleLabel') || 'STALE';
const actionSkipLabels = core.getInput('actionSkipLabels') || '';
const closeSkipLabels = core.getInput('closeSkipLabels') || '';
const showLogs = core.getInput('showLogs') || 'true';

const GH_TOKEN = core.getInput('ghToken', {
Expand All @@ -25,8 +27,10 @@ const options = {
staleAfter: +staleAfter,
closeAfter: +closeAfter,
staleComment,
closeSkipLabels,
closeComment,
staleLabel,
actionSkipLabels,
showLogs: showLogs === 'true',
};

Expand Down
26 changes: 25 additions & 1 deletion src/issueTriage.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,33 @@ class ActionIssueTriage {
try {
let isClosingDown = false;

let hasActionSkipLabel = false;
if (this.opts.actionSkipLabels) {
for (const label of issue.labels.map((i) => i.name)) {
if (this.opts.actionSkipLabels.split(',').indexOf(label) > 0) {
hasActionSkipLabel = true;
}
}
}

if (hasActionSkipLabel) {
continue;
}

let hasCloseSkipLabel = false;
if (this.opts.closeSkipLabels) {
for (const label of issue.labels.map((i) => i.name)) {
if (this.opts.closeSkipLabels.split(',').indexOf(label) > 0) {
hasCloseSkipLabel = true;
}
}
}


if (
this.opts.closeAfter > this.opts.staleAfter &&
this._isOlderThan(issue.updated_at, this.opts.closeAfter)
this._isOlderThan(issue.updated_at, this.opts.closeAfter) &&
!hasCloseSkipLabel
) {
isClosingDown = true;
}
Expand Down