2019-08-04 09:34:59 +08:00
|
|
|
import * as core from '@actions/core';
|
2020-04-17 01:57:59 +08:00
|
|
|
import {IssueProcessor, IssueProcessorOptions} from './IssueProcessor';
|
2019-08-04 09:34:59 +08:00
|
|
|
|
2020-04-15 01:28:00 +08:00
|
|
|
async function run(): Promise<void> {
|
2019-08-04 09:34:59 +08:00
|
|
|
try {
|
|
|
|
const args = getAndValidateArgs();
|
|
|
|
|
2020-04-17 01:57:59 +08:00
|
|
|
const processor: IssueProcessor = new IssueProcessor(args);
|
|
|
|
await processor.processIssues();
|
2019-08-07 04:25:08 +08:00
|
|
|
} catch (error) {
|
|
|
|
core.error(error);
|
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
|
|
|
}
|
2019-08-04 09:34:59 +08:00
|
|
|
|
2020-04-17 01:57:59 +08:00
|
|
|
function getAndValidateArgs(): IssueProcessorOptions {
|
2019-08-04 09:34:59 +08:00
|
|
|
const args = {
|
2021-01-15 20:07:08 +08:00
|
|
|
repoToken: core.getInput('repo-token'),
|
2019-08-07 04:25:08 +08:00
|
|
|
staleIssueMessage: core.getInput('stale-issue-message'),
|
2019-08-07 06:26:47 +08:00
|
|
|
stalePrMessage: core.getInput('stale-pr-message'),
|
2020-07-14 01:05:59 +08:00
|
|
|
closeIssueMessage: core.getInput('close-issue-message'),
|
|
|
|
closePrMessage: core.getInput('close-pr-message'),
|
2019-08-07 04:25:08 +08:00
|
|
|
daysBeforeStale: parseInt(
|
|
|
|
core.getInput('days-before-stale', {required: true})
|
|
|
|
),
|
2021-01-16 21:28:29 +08:00
|
|
|
daysBeforeIssueStale: parseInt(core.getInput('days-before-issue-stale')),
|
|
|
|
daysBeforePrStale: parseInt(core.getInput('days-before-pr-stale')),
|
2019-08-07 04:25:08 +08:00
|
|
|
daysBeforeClose: parseInt(
|
|
|
|
core.getInput('days-before-close', {required: true})
|
|
|
|
),
|
2021-01-16 21:28:29 +08:00
|
|
|
daysBeforeIssueClose: parseInt(core.getInput('days-before-issue-close')),
|
|
|
|
daysBeforePrClose: parseInt(core.getInput('days-before-pr-close')),
|
2019-08-07 04:25:08 +08:00
|
|
|
staleIssueLabel: core.getInput('stale-issue-label', {required: true}),
|
2020-09-09 03:32:42 +08:00
|
|
|
closeIssueLabel: core.getInput('close-issue-label'),
|
2020-04-16 09:33:09 +08:00
|
|
|
exemptIssueLabels: core.getInput('exempt-issue-labels'),
|
2019-08-07 04:25:08 +08:00
|
|
|
stalePrLabel: core.getInput('stale-pr-label', {required: true}),
|
2020-09-09 03:32:42 +08:00
|
|
|
closePrLabel: core.getInput('close-pr-label'),
|
2020-04-16 09:33:09 +08:00
|
|
|
exemptPrLabels: core.getInput('exempt-pr-labels'),
|
2019-09-27 21:33:20 +08:00
|
|
|
onlyLabels: core.getInput('only-labels'),
|
2019-08-07 04:25:08 +08:00
|
|
|
operationsPerRun: parseInt(
|
|
|
|
core.getInput('operations-per-run', {required: true})
|
2020-04-17 01:57:59 +08:00
|
|
|
),
|
2020-05-11 22:46:03 +08:00
|
|
|
removeStaleWhenUpdated: !(
|
|
|
|
core.getInput('remove-stale-when-updated') === 'false'
|
|
|
|
),
|
2020-06-24 01:55:24 +08:00
|
|
|
debugOnly: core.getInput('debug-only') === 'true',
|
2020-07-24 20:08:48 +08:00
|
|
|
ascending: core.getInput('ascending') === 'true',
|
|
|
|
skipStalePrMessage: core.getInput('skip-stale-pr-message') === 'true',
|
2021-01-15 19:49:38 +08:00
|
|
|
skipStaleIssueMessage: core.getInput('skip-stale-issue-message') === 'true',
|
|
|
|
deleteBranch: core.getInput('delete-branch') === 'true'
|
2019-08-04 09:34:59 +08:00
|
|
|
};
|
|
|
|
|
2020-04-15 01:28:00 +08:00
|
|
|
for (const numberInput of [
|
2019-08-07 04:25:08 +08:00
|
|
|
'days-before-stale',
|
2021-01-16 21:28:29 +08:00
|
|
|
'days-before-issue-stale',
|
|
|
|
'days-before-pr-stale',
|
2019-08-07 04:25:08 +08:00
|
|
|
'days-before-close',
|
2021-01-16 21:28:29 +08:00
|
|
|
'days-before-issue-close',
|
|
|
|
'days-before-pr-close',
|
2019-08-07 04:25:08 +08:00
|
|
|
'operations-per-run'
|
|
|
|
]) {
|
|
|
|
if (isNaN(parseInt(core.getInput(numberInput)))) {
|
2019-08-04 09:34:59 +08:00
|
|
|
throw Error(`input ${numberInput} did not parse to a valid integer`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return args;
|
|
|
|
}
|
|
|
|
|
|
|
|
run();
|