-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.ts
44 lines (38 loc) · 1.57 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import * as core from '@actions/core';
import * as github from '@actions/github';
import { StalePrFinder } from './stale-prs';
async function run() {
const token: string = core.getInput('github-token', { required: true });
const staleDays: string = core.getInput('stale-days', { required: true });
const responseDays: string = core.getInput('response-days', { required: true });
const importantChecksRegex: string = core.getInput('important-checks-regex');
const skipLabels: string = core.getInput('skip-labels');
const warnMessage: string = core.getInput('warn-message');
const closeMessage: string = core.getInput('close-message');
const closeLabel: string = core.getInput('close-label');
const dryRun: boolean = core.getInput('dry-run') !== '';
const finder = new StalePrFinder(token, {
owner: github.context.repo.owner,
repo: github.context.repo.repo,
staleDays: verifyInt(staleDays),
responseDays: verifyInt(responseDays),
importantChecksRegex: importantChecksRegex ? new RegExp(importantChecksRegex) : undefined,
skipLabels: skipLabels ? skipLabels.split(',') : undefined,
warnMessage: warnMessage ? warnMessage : undefined,
closeMessage: closeMessage ? closeMessage : undefined,
closeLabel: closeLabel ? closeLabel : undefined,
dryRun,
});
await finder.findAll();
console.log('Metrics', finder.metrics);
}
function verifyInt(x: string): number {
const num = parseInt(x, 10);
if (`${num}` !== x) {
throw new Error(`Not a number: ${x}`);
}
return num;
}
run().catch(error => {
core.setFailed(error.message);
});