stale/src/main.ts

63 lines
2.1 KiB
TypeScript
Raw Normal View History

2019-08-04 09:34:59 +08:00
import * as core from '@actions/core';
import {IssueProcessor, IssueProcessorOptions} from './IssueProcessor';
2019-08-04 09:34:59 +08:00
async function run(): Promise<void> {
2019-08-04 09:34:59 +08:00
try {
const args = getAndValidateArgs();
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
function getAndValidateArgs(): IssueProcessorOptions {
2019-08-04 09:34:59 +08:00
const args = {
2019-08-07 04:25:08 +08:00
repoToken: core.getInput('repo-token', {required: true}),
staleIssueMessage: core.getInput('stale-issue-message'),
2019-08-07 06:26:47 +08:00
stalePrMessage: core.getInput('stale-pr-message'),
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})
),
daysBeforeClose: parseInt(
core.getInput('days-before-close', {required: true})
),
staleIssueLabel: core.getInput('stale-issue-label', {required: true}),
closeIssueLabel: core.getInput('close-issue-label'),
exemptIssueLabels: core.getInput('exempt-issue-labels'),
2019-08-07 04:25:08 +08:00
stalePrLabel: core.getInput('stale-pr-label', {required: true}),
closePrLabel: core.getInput('close-pr-label'),
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})
),
removeStaleWhenUpdated: !(
core.getInput('remove-stale-when-updated') === 'false'
),
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',
deleteBranch: core.getInput('delete-branch') === 'true'
2019-08-04 09:34:59 +08:00
};
for (const numberInput of [
2019-08-07 04:25:08 +08:00
'days-before-stale',
'days-before-close',
'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();