mirror of
https://github.com/actions/stale.git
synced 2025-12-27 18:58:16 +00:00
Compare commits
8 Commits
hross-proc
...
v3.0.11
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1849651e2a | ||
|
|
adc83cbd46 | ||
|
|
691fea805f | ||
|
|
65b38a69a5 | ||
|
|
1919ea432e | ||
|
|
1402601e7a | ||
|
|
655dd09f5f | ||
|
|
13b324e4b2 |
@@ -40,8 +40,10 @@ const DefaultProcessorOptions: IssueProcessorOptions = Object.freeze({
|
|||||||
daysBeforeStale: 1,
|
daysBeforeStale: 1,
|
||||||
daysBeforeClose: 30,
|
daysBeforeClose: 30,
|
||||||
staleIssueLabel: 'Stale',
|
staleIssueLabel: 'Stale',
|
||||||
|
closeIssueLabel: '',
|
||||||
exemptIssueLabels: '',
|
exemptIssueLabels: '',
|
||||||
stalePrLabel: 'Stale',
|
stalePrLabel: 'Stale',
|
||||||
|
closePrLabel: '',
|
||||||
exemptPrLabels: '',
|
exemptPrLabels: '',
|
||||||
onlyLabels: '',
|
onlyLabels: '',
|
||||||
operationsPerRun: 100,
|
operationsPerRun: 100,
|
||||||
|
|||||||
@@ -22,12 +22,16 @@ inputs:
|
|||||||
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'
|
||||||
|
close-issue-label:
|
||||||
|
description: 'The label to apply when an issue is closed.'
|
||||||
exempt-issue-labels:
|
exempt-issue-labels:
|
||||||
description: 'The labels to apply when an issue is exempt from being marked stale. Separate multiple labels with commas (eg. "label1,label2")'
|
description: 'The labels to apply when an issue is exempt from being marked stale. Separate multiple labels with commas (eg. "label1,label2")'
|
||||||
default: ''
|
default: ''
|
||||||
stale-pr-label:
|
stale-pr-label:
|
||||||
description: 'The label to apply when a pull request is stale.'
|
description: 'The label to apply when a pull request is stale.'
|
||||||
default: 'Stale'
|
default: 'Stale'
|
||||||
|
close-pr-label:
|
||||||
|
description: 'The label to apply when a pull request is closed.'
|
||||||
exempt-pr-labels:
|
exempt-pr-labels:
|
||||||
description: 'The labels to apply when a pull request is exempt from being marked stale. Separate multiple labels with commas (eg. "label1,label2")'
|
description: 'The labels to apply when a pull request is exempt from being marked stale. Separate multiple labels with commas (eg. "label1,label2")'
|
||||||
default: ''
|
default: ''
|
||||||
|
|||||||
26
dist/index.js
vendored
26
dist/index.js
vendored
@@ -1455,8 +1455,10 @@ function getAndValidateArgs() {
|
|||||||
daysBeforeStale: parseInt(core.getInput('days-before-stale', { required: true })),
|
daysBeforeStale: parseInt(core.getInput('days-before-stale', { required: true })),
|
||||||
daysBeforeClose: parseInt(core.getInput('days-before-close', { required: true })),
|
daysBeforeClose: parseInt(core.getInput('days-before-close', { required: true })),
|
||||||
staleIssueLabel: core.getInput('stale-issue-label', { required: true }),
|
staleIssueLabel: core.getInput('stale-issue-label', { required: true }),
|
||||||
|
closeIssueLabel: core.getInput('close-issue-label'),
|
||||||
exemptIssueLabels: core.getInput('exempt-issue-labels'),
|
exemptIssueLabels: core.getInput('exempt-issue-labels'),
|
||||||
stalePrLabel: core.getInput('stale-pr-label', { required: true }),
|
stalePrLabel: core.getInput('stale-pr-label', { required: true }),
|
||||||
|
closePrLabel: core.getInput('close-pr-label'),
|
||||||
exemptPrLabels: core.getInput('exempt-pr-labels'),
|
exemptPrLabels: core.getInput('exempt-pr-labels'),
|
||||||
onlyLabels: core.getInput('only-labels'),
|
onlyLabels: core.getInput('only-labels'),
|
||||||
operationsPerRun: parseInt(core.getInput('operations-per-run', { required: true })),
|
operationsPerRun: parseInt(core.getInput('operations-per-run', { required: true })),
|
||||||
@@ -2588,6 +2590,9 @@ class IssueProcessor {
|
|||||||
const staleLabel = isPr
|
const staleLabel = isPr
|
||||||
? this.options.stalePrLabel
|
? this.options.stalePrLabel
|
||||||
: this.options.staleIssueLabel;
|
: this.options.staleIssueLabel;
|
||||||
|
const closeLabel = isPr
|
||||||
|
? this.options.closePrLabel
|
||||||
|
: this.options.closeIssueLabel;
|
||||||
const exemptLabels = IssueProcessor.parseCommaSeparatedString(isPr ? this.options.exemptPrLabels : this.options.exemptIssueLabels);
|
const exemptLabels = IssueProcessor.parseCommaSeparatedString(isPr ? this.options.exemptPrLabels : this.options.exemptIssueLabels);
|
||||||
const skipMessage = isPr
|
const skipMessage = isPr
|
||||||
? this.options.skipStalePrMessage
|
? this.options.skipStalePrMessage
|
||||||
@@ -2623,7 +2628,7 @@ class IssueProcessor {
|
|||||||
// process the issue if it was marked stale
|
// process the issue if it was marked stale
|
||||||
if (isStale) {
|
if (isStale) {
|
||||||
core.info(`Found a stale ${issueType}`);
|
core.info(`Found a stale ${issueType}`);
|
||||||
yield this.processStaleIssue(issue, issueType, staleLabel, closeMessage);
|
yield this.processStaleIssue(issue, issueType, staleLabel, closeMessage, closeLabel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.operationsLeft <= 0) {
|
if (this.operationsLeft <= 0) {
|
||||||
@@ -2635,7 +2640,7 @@ class IssueProcessor {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// handle all of the stale issue logic when we find a stale issue
|
// handle all of the stale issue logic when we find a stale issue
|
||||||
processStaleIssue(issue, issueType, staleLabel, closeMessage) {
|
processStaleIssue(issue, issueType, staleLabel, closeMessage, closeLabel) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const markedStaleOn = (yield this.getLabelCreationDate(issue, staleLabel)) || issue.updated_at;
|
const markedStaleOn = (yield this.getLabelCreationDate(issue, staleLabel)) || issue.updated_at;
|
||||||
core.info(`Issue #${issue.number} marked stale on: ${markedStaleOn}`);
|
core.info(`Issue #${issue.number} marked stale on: ${markedStaleOn}`);
|
||||||
@@ -2654,7 +2659,7 @@ class IssueProcessor {
|
|||||||
}
|
}
|
||||||
if (!issueHasComments && !issueHasUpdate) {
|
if (!issueHasComments && !issueHasUpdate) {
|
||||||
core.info(`Closing ${issueType} because it was last updated on ${issue.updated_at}`);
|
core.info(`Closing ${issueType} because it was last updated on ${issue.updated_at}`);
|
||||||
yield this.closeIssue(issue, closeMessage);
|
yield this.closeIssue(issue, closeMessage, closeLabel);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info(`Stale ${issueType} is not old enough to close yet (hasComments? ${issueHasComments}, hasUpdate? ${issueHasUpdate}`);
|
core.info(`Stale ${issueType} is not old enough to close yet (hasComments? ${issueHasComments}, hasUpdate? ${issueHasUpdate}`);
|
||||||
@@ -2758,7 +2763,7 @@ class IssueProcessor {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Close an issue based on staleness
|
// Close an issue based on staleness
|
||||||
closeIssue(issue, closeMessage) {
|
closeIssue(issue, closeMessage, closeLabel) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info(`Closing issue #${issue.number} - ${issue.title} for being stale`);
|
core.info(`Closing issue #${issue.number} - ${issue.title} for being stale`);
|
||||||
this.closedIssues.push(issue);
|
this.closedIssues.push(issue);
|
||||||
@@ -2779,6 +2784,19 @@ class IssueProcessor {
|
|||||||
core.error(`Error creating a comment: ${error.message}`);
|
core.error(`Error creating a comment: ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (closeLabel) {
|
||||||
|
try {
|
||||||
|
yield this.client.issues.addLabels({
|
||||||
|
owner: github_1.context.repo.owner,
|
||||||
|
repo: github_1.context.repo.repo,
|
||||||
|
issue_number: issue.number,
|
||||||
|
labels: [closeLabel]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
core.error(`Error adding a label: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
yield this.client.issues.update({
|
yield this.client.issues.update({
|
||||||
owner: github_1.context.repo.owner,
|
owner: github_1.context.repo.owner,
|
||||||
|
|||||||
779
package-lock.json
generated
779
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -25,7 +25,7 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.4",
|
"@actions/core": "^1.2.5",
|
||||||
"@actions/github": "^4.0.0",
|
"@actions/github": "^4.0.0",
|
||||||
"@octokit/rest": "^18.0.4",
|
"@octokit/rest": "^18.0.4",
|
||||||
"semver": "^7.3.2"
|
"semver": "^7.3.2"
|
||||||
@@ -33,16 +33,16 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/semver": "^7.3.1",
|
"@types/semver": "^7.3.1",
|
||||||
"@types/jest": "^26.0.10",
|
"@types/jest": "^26.0.10",
|
||||||
"@types/node": "^14.6.0",
|
"@types/node": "^14.10.0",
|
||||||
"@typescript-eslint/parser": "^3.10.1",
|
"@typescript-eslint/parser": "^3.10.1",
|
||||||
"@vercel/ncc": "^0.23.0",
|
"@vercel/ncc": "^0.24.0",
|
||||||
"eslint": "^7.7.0",
|
"eslint": "^7.7.0",
|
||||||
"eslint-plugin-github": "^4.0.1",
|
"eslint-plugin-github": "^4.0.1",
|
||||||
"eslint-plugin-jest": "^23.20.0",
|
"eslint-plugin-jest": "^23.20.0",
|
||||||
"jest": "^24.9.0",
|
"jest": "^24.9.0",
|
||||||
"jest-circus": "^26.1.0",
|
"jest-circus": "^26.4.2",
|
||||||
"js-yaml": "^3.14.0",
|
"js-yaml": "^3.14.0",
|
||||||
"prettier": "^2.0.5",
|
"prettier": "^2.1.1",
|
||||||
"ts-jest": "^24.2.0",
|
"ts-jest": "^24.2.0",
|
||||||
"typescript": "^4.0.2"
|
"typescript": "^4.0.2"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,10 @@ export interface IssueProcessorOptions {
|
|||||||
daysBeforeStale: number;
|
daysBeforeStale: number;
|
||||||
daysBeforeClose: number;
|
daysBeforeClose: number;
|
||||||
staleIssueLabel: string;
|
staleIssueLabel: string;
|
||||||
|
closeIssueLabel: string;
|
||||||
exemptIssueLabels: string;
|
exemptIssueLabels: string;
|
||||||
stalePrLabel: string;
|
stalePrLabel: string;
|
||||||
|
closePrLabel: string;
|
||||||
exemptPrLabels: string;
|
exemptPrLabels: string;
|
||||||
onlyLabels: string;
|
onlyLabels: string;
|
||||||
operationsPerRun: number;
|
operationsPerRun: number;
|
||||||
@@ -126,6 +128,9 @@ export class IssueProcessor {
|
|||||||
const staleLabel: string = isPr
|
const staleLabel: string = isPr
|
||||||
? this.options.stalePrLabel
|
? this.options.stalePrLabel
|
||||||
: this.options.staleIssueLabel;
|
: this.options.staleIssueLabel;
|
||||||
|
const closeLabel: string = isPr
|
||||||
|
? this.options.closePrLabel
|
||||||
|
: this.options.closeIssueLabel;
|
||||||
const exemptLabels = IssueProcessor.parseCommaSeparatedString(
|
const exemptLabels = IssueProcessor.parseCommaSeparatedString(
|
||||||
isPr ? this.options.exemptPrLabels : this.options.exemptIssueLabels
|
isPr ? this.options.exemptPrLabels : this.options.exemptIssueLabels
|
||||||
);
|
);
|
||||||
@@ -184,7 +189,8 @@ export class IssueProcessor {
|
|||||||
issue,
|
issue,
|
||||||
issueType,
|
issueType,
|
||||||
staleLabel,
|
staleLabel,
|
||||||
closeMessage
|
closeMessage,
|
||||||
|
closeLabel
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -203,7 +209,8 @@ export class IssueProcessor {
|
|||||||
issue: Issue,
|
issue: Issue,
|
||||||
issueType: string,
|
issueType: string,
|
||||||
staleLabel: string,
|
staleLabel: string,
|
||||||
closeMessage?: string
|
closeMessage?: string,
|
||||||
|
closeLabel?: string
|
||||||
) {
|
) {
|
||||||
const markedStaleOn: string =
|
const markedStaleOn: string =
|
||||||
(await this.getLabelCreationDate(issue, staleLabel)) || issue.updated_at;
|
(await this.getLabelCreationDate(issue, staleLabel)) || issue.updated_at;
|
||||||
@@ -240,7 +247,7 @@ export class IssueProcessor {
|
|||||||
core.info(
|
core.info(
|
||||||
`Closing ${issueType} because it was last updated on ${issue.updated_at}`
|
`Closing ${issueType} because it was last updated on ${issue.updated_at}`
|
||||||
);
|
);
|
||||||
await this.closeIssue(issue, closeMessage);
|
await this.closeIssue(issue, closeMessage, closeLabel);
|
||||||
} else {
|
} else {
|
||||||
core.info(
|
core.info(
|
||||||
`Stale ${issueType} is not old enough to close yet (hasComments? ${issueHasComments}, hasUpdate? ${issueHasUpdate}`
|
`Stale ${issueType} is not old enough to close yet (hasComments? ${issueHasComments}, hasUpdate? ${issueHasUpdate}`
|
||||||
@@ -370,7 +377,11 @@ export class IssueProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Close an issue based on staleness
|
// Close an issue based on staleness
|
||||||
private async closeIssue(issue: Issue, closeMessage?: string): Promise<void> {
|
private async closeIssue(
|
||||||
|
issue: Issue,
|
||||||
|
closeMessage?: string,
|
||||||
|
closeLabel?: string
|
||||||
|
): Promise<void> {
|
||||||
core.info(
|
core.info(
|
||||||
`Closing issue #${issue.number} - ${issue.title} for being stale`
|
`Closing issue #${issue.number} - ${issue.title} for being stale`
|
||||||
);
|
);
|
||||||
@@ -396,6 +407,19 @@ export class IssueProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (closeLabel) {
|
||||||
|
try {
|
||||||
|
await this.client.issues.addLabels({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: issue.number,
|
||||||
|
labels: [closeLabel]
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
core.error(`Error adding a label: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.client.issues.update({
|
await this.client.issues.update({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
|
|||||||
@@ -27,8 +27,10 @@ function getAndValidateArgs(): IssueProcessorOptions {
|
|||||||
core.getInput('days-before-close', {required: true})
|
core.getInput('days-before-close', {required: true})
|
||||||
),
|
),
|
||||||
staleIssueLabel: core.getInput('stale-issue-label', {required: true}),
|
staleIssueLabel: core.getInput('stale-issue-label', {required: true}),
|
||||||
|
closeIssueLabel: core.getInput('close-issue-label'),
|
||||||
exemptIssueLabels: core.getInput('exempt-issue-labels'),
|
exemptIssueLabels: core.getInput('exempt-issue-labels'),
|
||||||
stalePrLabel: core.getInput('stale-pr-label', {required: true}),
|
stalePrLabel: core.getInput('stale-pr-label', {required: true}),
|
||||||
|
closePrLabel: core.getInput('close-pr-label'),
|
||||||
exemptPrLabels: core.getInput('exempt-pr-labels'),
|
exemptPrLabels: core.getInput('exempt-pr-labels'),
|
||||||
onlyLabels: core.getInput('only-labels'),
|
onlyLabels: core.getInput('only-labels'),
|
||||||
operationsPerRun: parseInt(
|
operationsPerRun: parseInt(
|
||||||
|
|||||||
Reference in New Issue
Block a user