mirror of
https://github.com/actions/stale.git
synced 2025-12-13 21:53:25 +00:00
Add a start date option to ignore old issues and PRs (#269)
* docs(readme): add a small precision about the operations-per-run closes #230 * chore(lint): ignore the lib folder for prettier * chore(date): add a function to check if a date is valid * chore(date): add a function to get a humanized date * chore(date): add a function to check if the date is more recent than * feat(date): add a start date to ignore old issues and PRs closes #174 * docs(readme): change the date to match the description * chore(date): add a better type for the date * docs(date): add missing JSDoc about the return type * chore(rebase): fix issues due to rebase * docs(readme): fix table formatting issues
This commit is contained in:
committed by
GitHub
parent
7f340a46f3
commit
f698371c0d
20
src/main.ts
20
src/main.ts
@@ -1,4 +1,5 @@
|
||||
import * as core from '@actions/core';
|
||||
import {isValidDate} from './functions/dates/is-valid-date';
|
||||
import {IssueProcessor, IssueProcessorOptions} from './IssueProcessor';
|
||||
|
||||
async function run(): Promise<void> {
|
||||
@@ -14,7 +15,7 @@ async function run(): Promise<void> {
|
||||
}
|
||||
|
||||
function getAndValidateArgs(): IssueProcessorOptions {
|
||||
const args = {
|
||||
const args: IssueProcessorOptions = {
|
||||
repoToken: core.getInput('repo-token'),
|
||||
staleIssueMessage: core.getInput('stale-issue-message'),
|
||||
stalePrMessage: core.getInput('stale-pr-message'),
|
||||
@@ -47,7 +48,11 @@ function getAndValidateArgs(): IssueProcessorOptions {
|
||||
ascending: core.getInput('ascending') === 'true',
|
||||
skipStalePrMessage: core.getInput('skip-stale-pr-message') === 'true',
|
||||
skipStaleIssueMessage: core.getInput('skip-stale-issue-message') === 'true',
|
||||
deleteBranch: core.getInput('delete-branch') === 'true'
|
||||
deleteBranch: core.getInput('delete-branch') === 'true',
|
||||
startDate:
|
||||
core.getInput('start-date') !== ''
|
||||
? core.getInput('start-date')
|
||||
: undefined
|
||||
};
|
||||
|
||||
for (const numberInput of [
|
||||
@@ -64,6 +69,17 @@ function getAndValidateArgs(): IssueProcessorOptions {
|
||||
}
|
||||
}
|
||||
|
||||
for (const optionalDateInput of ['start-date']) {
|
||||
// Ignore empty dates because it is considered as the right type for a default value (so a valid one)
|
||||
if (core.getInput(optionalDateInput) !== '') {
|
||||
if (!isValidDate(new Date(core.getInput(optionalDateInput)))) {
|
||||
throw new Error(
|
||||
`input ${optionalDateInput} did not parse to a valid date`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user