From 548ed5ce961834218010421fac4bc97af6167d57 Mon Sep 17 00:00:00 2001 From: yuiseki Date: Tue, 30 Mar 2021 05:54:20 +0000 Subject: [PATCH 1/7] add closeSkipLabels --- README.md | 1 + action.yml | 3 +++ src/issueTriage.js | 12 +++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ac5b314..e734c93 100644 --- a/README.md +++ b/README.md @@ -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]*, 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` diff --git a/action.yml b/action.yml index d652807..01b0914 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,9 @@ inputs: 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 diff --git a/src/issueTriage.js b/src/issueTriage.js index 9fb864e..287ad10 100644 --- a/src/issueTriage.js +++ b/src/issueTriage.js @@ -38,9 +38,19 @@ class ActionIssueTriage { try { let isClosingDown = false; + let hasCloseSkipLabel = false; + if (this.opts.closeSkipLabels) { + for (const label of issue.labels) { + if (this.opts.closeSkipLabels.indexOf(label)) { + 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; } From be9a60893ad9bedb136aa5b371d25914e372df59 Mon Sep 17 00:00:00 2001 From: yuiseki Date: Tue, 30 Mar 2021 06:13:09 +0000 Subject: [PATCH 2/7] tested at local --- README.md | 1 + dist/index.js | 16 ++++++++++++++-- src/index.js | 4 +++- src/issueTriage.js | 4 ++-- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e734c93..b4f8765 100644 --- a/README.md +++ b/README.md @@ -45,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 ``` diff --git a/dist/index.js b/dist/index.js index 5a6d987..487ded1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4611,9 +4611,19 @@ class ActionIssueTriage { try { let isClosingDown = false; + 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; } @@ -7743,8 +7753,9 @@ 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 closeSkipLabels = core.getInput('closeSkipLabels') || ''; const showLogs = core.getInput('showLogs') || 'true'; const GH_TOKEN = core.getInput('ghToken', { @@ -7757,6 +7768,7 @@ const options = { staleAfter: +staleAfter, closeAfter: +closeAfter, staleComment, + closeSkipLabels, closeComment, staleLabel, showLogs: showLogs === 'true', diff --git a/src/index.js b/src/index.js index e54e696..b26aceb 100644 --- a/src/index.js +++ b/src/index.js @@ -11,8 +11,9 @@ 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 closeSkipLabels = core.getInput('closeSkipLabels') || ''; const showLogs = core.getInput('showLogs') || 'true'; const GH_TOKEN = core.getInput('ghToken', { @@ -25,6 +26,7 @@ const options = { staleAfter: +staleAfter, closeAfter: +closeAfter, staleComment, + closeSkipLabels, closeComment, staleLabel, showLogs: showLogs === 'true', diff --git a/src/issueTriage.js b/src/issueTriage.js index 287ad10..9b9b172 100644 --- a/src/issueTriage.js +++ b/src/issueTriage.js @@ -40,8 +40,8 @@ class ActionIssueTriage { let hasCloseSkipLabel = false; if (this.opts.closeSkipLabels) { - for (const label of issue.labels) { - if (this.opts.closeSkipLabels.indexOf(label)) { + for (const label of issue.labels.map((i) => i.name)) { + if (this.opts.closeSkipLabels.split(',').indexOf(label) > 0) { hasCloseSkipLabel = true; } } From 868c21014d89678caa29f7bcb8463bf50026d1f1 Mon Sep 17 00:00:00 2001 From: yuiseki Date: Tue, 30 Mar 2021 06:15:24 +0000 Subject: [PATCH 3/7] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b4f8765..81eb883 100644 --- a/README.md +++ b/README.md @@ -19,7 +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]*, list of labels for skip closing the issue +- `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` From 5ee9cdbcd735c359e8896276fd25a204ca80aa3f Mon Sep 17 00:00:00 2001 From: yuiseki Date: Mon, 10 May 2021 16:24:29 +0900 Subject: [PATCH 4/7] add action-skip-labels --- action.yml | 4 ++++ src/index.js | 2 ++ 2 files changed, 6 insertions(+) diff --git a/action.yml b/action.yml index d652807..03df4f5 100644 --- a/action.yml +++ b/action.yml @@ -17,6 +17,10 @@ inputs: description: label to be set to the stale issue required: false default: "STALE 📺" + actionSkipLabels: + description: labels to do nothing + required: false + default: "" staleComment: description: a template comment to be placed when handling the issue required: false diff --git a/src/index.js b/src/index.js index e54e696..3ebcccb 100644 --- a/src/index.js +++ b/src/index.js @@ -13,6 +13,7 @@ const closeAfter = core.getInput('closeAfter') || 0; const staleComment = core.getInput('staleComment') || staleCommentDefault; const closeComment = core.getInput('staleComment') || closeCommentDefault; const staleLabel = core.getInput('staleLabel') || 'STALE'; +const actionSkipLabels = core.getInput('actionSkipLabels') || ''; const showLogs = core.getInput('showLogs') || 'true'; const GH_TOKEN = core.getInput('ghToken', { @@ -27,6 +28,7 @@ const options = { staleComment, closeComment, staleLabel, + actionSkipLabels, showLogs: showLogs === 'true', }; From a10bd12e0cb37aa28c908ff7cabf1b42fc27639f Mon Sep 17 00:00:00 2001 From: yuiseki Date: Mon, 10 May 2021 16:27:50 +0900 Subject: [PATCH 5/7] update impl --- action.yml | 3 +-- src/issueTriage.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 03df4f5..581aa3f 100644 --- a/action.yml +++ b/action.yml @@ -18,9 +18,8 @@ inputs: required: false default: "STALE 📺" actionSkipLabels: - description: labels to do nothing + description: list of labels to do nothing required: false - default: "" staleComment: description: a template comment to be placed when handling the issue required: false diff --git a/src/issueTriage.js b/src/issueTriage.js index 9fb864e..2af6fa2 100644 --- a/src/issueTriage.js +++ b/src/issueTriage.js @@ -38,6 +38,19 @@ 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; + } + if ( this.opts.closeAfter > this.opts.staleAfter && this._isOlderThan(issue.updated_at, this.opts.closeAfter) From d959611787c87fc41abcc17b2b9e795a567c8dd2 Mon Sep 17 00:00:00 2001 From: yuiseki Date: Mon, 10 May 2021 16:31:44 +0900 Subject: [PATCH 6/7] update dist --- dist/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dist/index.js b/dist/index.js index 5a6d987..2df58de 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4611,6 +4611,19 @@ 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; + } + if ( this.opts.closeAfter > this.opts.staleAfter && this._isOlderThan(issue.updated_at, this.opts.closeAfter) @@ -7745,6 +7758,7 @@ const closeAfter = core.getInput('closeAfter') || 0; const staleComment = core.getInput('staleComment') || staleCommentDefault; const closeComment = core.getInput('staleComment') || closeCommentDefault; const staleLabel = core.getInput('staleLabel') || 'STALE'; +const actionSkipLabels = core.getInput('actionSkipLabels') || ''; const showLogs = core.getInput('showLogs') || 'true'; const GH_TOKEN = core.getInput('ghToken', { @@ -7759,6 +7773,7 @@ const options = { staleComment, closeComment, staleLabel, + actionSkipLabels, showLogs: showLogs === 'true', }; From fa0adf0038bcca52ec2c9a4cc09d1787d8d7b6d7 Mon Sep 17 00:00:00 2001 From: yuiseki Date: Mon, 10 May 2021 16:35:55 +0900 Subject: [PATCH 7/7] rename action --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 01b0914..f3439ba 100644 --- a/action.yml +++ b/action.yml @@ -1,4 +1,4 @@ -name: 'Issue triage' +name: 'Issue triage customized' description: "Deals with stale issues in your project." author: "krizzu" inputs: