From 5e528060cc2e5841dfc4cd97bcaae19a5bc1cd89 Mon Sep 17 00:00:00 2001 From: Ross Brodbeck Date: Fri, 28 Aug 2020 13:58:11 -0400 Subject: [PATCH] Add exemption for processing draft PRs --- action.yml | 3 +++ src/IssueProcessor.ts | 7 +++++++ src/main.ts | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 34542235..71081632 100644 --- a/action.yml +++ b/action.yml @@ -52,6 +52,9 @@ inputs: skip-stale-issue-message: description: 'Skip adding stale message when marking an issue as stale.' default: false + process-drafts: + description: 'Should the draft PRs be marked stale? If set to true, draft PRs will be included in processing.' + default: false runs: using: 'node12' main: 'dist/index.js' diff --git a/src/IssueProcessor.ts b/src/IssueProcessor.ts index 0e85cb2a..e973c002 100644 --- a/src/IssueProcessor.ts +++ b/src/IssueProcessor.ts @@ -10,6 +10,7 @@ export interface Issue { pull_request: any; state: string; locked: boolean; + draft: boolean; } export interface User { @@ -50,6 +51,7 @@ export interface IssueProcessorOptions { ascending: boolean; skipStaleIssueMessage: boolean; skipStalePrMessage: boolean; + processDrafts: boolean; } /*** @@ -150,6 +152,11 @@ export class IssueProcessor { continue; // don't process locked issues } + if (issue.draft && !this.options.processDrafts) { + core.info(`Skipping ${issueType} because it is a draft`); + continue; // don't process drafts + } + if ( exemptLabels.some((exemptLabel: string) => IssueProcessor.isLabeled(issue, exemptLabel) diff --git a/src/main.ts b/src/main.ts index 550509f8..c9ab53a8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -40,7 +40,8 @@ function getAndValidateArgs(): IssueProcessorOptions { debugOnly: core.getInput('debug-only') === 'true', ascending: core.getInput('ascending') === 'true', skipStalePrMessage: core.getInput('skip-stale-pr-message') === 'true', - skipStaleIssueMessage: core.getInput('skip-stale-issue-message') === 'true' + skipStaleIssueMessage: core.getInput('skip-stale-issue-message') === 'true', + processDrafts: core.getInput('process-drafts') === 'true' }; for (const numberInput of [