import * as core from '@actions/core'; import {IssueProcessor, IssueProcessorOptions} from './IssueProcessor'; async function run(): Promise { try { const args = getAndValidateArgs(); const processor: IssueProcessor = new IssueProcessor(args); await processor.processIssues(); } catch (error) { core.error(error); core.setFailed(error.message); } } function getAndValidateArgs(): IssueProcessorOptions { const args = { repoToken: core.getInput('repo-token', {required: true}), staleIssueMessage: core.getInput('stale-issue-message'), stalePrMessage: core.getInput('stale-pr-message'), 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}), exemptIssueLabels: core.getInput('exempt-issue-labels'), stalePrLabel: core.getInput('stale-pr-label', {required: true}), exemptPrLabels: core.getInput('exempt-pr-labels'), onlyLabels: core.getInput('only-labels'), operationsPerRun: parseInt( core.getInput('operations-per-run', {required: true}) ), debugOnly: core.getInput('debug-only') === 'true' }; for (const numberInput of [ 'days-before-stale', 'days-before-close', 'operations-per-run' ]) { if (isNaN(parseInt(core.getInput(numberInput)))) { throw Error(`input ${numberInput} did not parse to a valid integer`); } } return args; } run();