Compare commits

..

1 Commits

Author SHA1 Message Date
Danny McCormick
0d4fcbf2f9 Packag nits 2019-08-07 10:14:36 -04:00
3 changed files with 21 additions and 18 deletions

View File

@@ -6,24 +6,24 @@ inputs:
description: 'Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }}' description: 'Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }}'
required: true required: true
stale-issue-message: stale-issue-message:
description: 'The message to post on the issue when tagging it. If none provided, will not mark issues stale.' description: 'The message to post on the issue when tagging it. If none provided, will not mark iusses stale.'
stale-pr-message: stale-pr-message:
description: 'The message to post on the pr when tagging it. If none provided, will not mark pull requests stale.' description: 'The message to post on the pr when tagging it. If none provided, will not mark prs stale.'
days-before-stale: days-before-stale:
description: 'The number of days old an issue can be before marking it stale' description: 'The number of days old an issue can be before marking it stale'
default: 60 default: 60
days-before-close: days-before-close:
description: 'The number of days to wait to close an issue or pull request after it being marked stale' description: 'The number of days to wait to close an issue or pr after it being marked stale'
default: 7 default: 7
stale-issue-label: stale-issue-label:
description: 'The label to apply when an issue is stale' description: 'The label to apply when an issue is stale'
default: 'Stale' default: 'Stale'
stale-pr-label: stale-pr-label:
description: 'The label to apply when a pull request is stale' description: 'The label to apply when a pr is stale'
default: 'Stale' default: 'Stale'
operations-per-run: operations-per-run:
description: 'The maximum number of operations per run, used to control rate limiting' description: 'The maximum number of operations per run, used to control rate limiting'
default: 30 default: 30
runs: runs:
using: 'node12' using: 'node12'
main: 'lib/main.js' main: 'lib/main.js'

View File

@@ -12,12 +12,12 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/actions/stale.git" "url": "git+https://github.com/actions/start-vm-action.git"
}, },
"keywords": [ "keywords": [
"actions", "actions",
"node", "node",
"stale" "setup"
], ],
"author": "GitHub", "author": "GitHub",
"license": "MIT", "license": "MIT",

View File

@@ -2,9 +2,6 @@ import * as core from '@actions/core';
import * as github from '@actions/github'; import * as github from '@actions/github';
import * as Octokit from '@octokit/rest'; import * as Octokit from '@octokit/rest';
type Issue = Octokit.IssuesListForRepoResponseItem;
type IssueLabel = Octokit.IssuesListForRepoResponseItemLabelsItem;
type Args = { type Args = {
repoToken: string; repoToken: string;
staleIssueMessage: string; staleIssueMessage: string;
@@ -54,7 +51,7 @@ async function processIssues(
let staleMessage = isPr ? args.stalePrMessage : args.staleIssueMessage; let staleMessage = isPr ? args.stalePrMessage : args.staleIssueMessage;
if (!staleMessage) { if (!staleMessage) {
core.debug(`skipping ${isPr ? 'pr' : 'issue'} due to empty message`); core.debug(`skipping ${isPr ? "pr" : "issue"} due to empty message`);
continue; continue;
} }
@@ -85,14 +82,20 @@ async function processIssues(
return await processIssues(client, args, operationsLeft, page + 1); return await processIssues(client, args, operationsLeft, page + 1);
} }
function isLabeledStale(issue: Issue, label: string): boolean { function isLabeledStale(
const labelComparer: (l: IssueLabel) => boolean = l => issue: Octokit.IssuesListForRepoResponseItem,
label.localeCompare(l.name, undefined, {sensitivity: 'accent'}) === 0; label: string
): boolean {
const labelComparer = l =>
label.localeCompare(l.name, undefined, {sensitivity: 'accent'});
return issue.labels.filter(labelComparer).length > 0; return issue.labels.filter(labelComparer).length > 0;
} }
function wasLastUpdatedBefore(issue: Issue, num_days: number): boolean { function wasLastUpdatedBefore(
const daysInMillis = 1000 * 60 * 60 * 24 * num_days; issue: Octokit.IssuesListForRepoResponseItem,
num_days: number
): boolean {
const daysInMillis = 1000 * 60 * 60 * num_days;
const millisSinceLastUpdated = const millisSinceLastUpdated =
new Date().getTime() - new Date(issue.updated_at).getTime(); new Date().getTime() - new Date(issue.updated_at).getTime();
return millisSinceLastUpdated >= daysInMillis; return millisSinceLastUpdated >= daysInMillis;
@@ -100,7 +103,7 @@ function wasLastUpdatedBefore(issue: Issue, num_days: number): boolean {
async function markStale( async function markStale(
client: github.GitHub, client: github.GitHub,
issue: Issue, issue: Octokit.IssuesListForRepoResponseItem,
staleMessage: string, staleMessage: string,
staleLabel: string staleLabel: string
): Promise<number> { ): Promise<number> {
@@ -125,7 +128,7 @@ async function markStale(
async function closeIssue( async function closeIssue(
client: github.GitHub, client: github.GitHub,
issue: Issue issue: Octokit.IssuesListForRepoResponseItem
): Promise<number> { ): Promise<number> {
core.debug(`closing issue ${issue.title} for being stale`); core.debug(`closing issue ${issue.title} for being stale`);