Skip to content

Commit

Permalink
Require close-comment
Browse files Browse the repository at this point in the history
Co-authored-by: Wryn (yage) Wagner <[email protected]>
  • Loading branch information
paescuj and wrynegade committed Aug 6, 2024
1 parent 4df44fa commit 4558b9c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
with:
stale-label: stale
days-before-close: 7
close-message: Closing this issue as it has become stale.
dry-run: true

- name: Check output
Expand Down
7 changes: 4 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ inputs:
default: ${{ github.token }}
github-repo:
required: true
description: GitHub `author/repository` for which stale issues are paused
description: GitHub `owner/repository` for which stale issues are paused
default: ${{ github.repository }}
stale-label:
required: true
description: Label which marks an issue as stale
days-before-close:
required: true
description: Days before an issue is closed after the stale label has been added it
description: Days before an issue is closed after the stale label has been added to it
close-comment:
required: true
description: Comment which will be added to issues when closing
dry-run:
description: Run the action without effectively closing stale issues
default: false
default: 'false'

outputs:
closed-issues:
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions src/lib/close-issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ import core from '@actions/core';
import type { Config } from './get-config.js';
import type { Issue } from './get-stale-issues.js';

export async function closeIssue({ octokit, ownerRepo, closeMessage, dryRun }: Config, { number, url, staleSince }: Issue) {
export async function closeIssue({ dryRun, octokit, ownerRepo, closeMessage }: Config, { number, url, staleSince }: Issue) {
if (dryRun) {
core.info(`Issue #${number} (${url}) is stale since ${staleSince} and would have been closed (dry-run)`);
return;
}

if (closeMessage) {
await octokit.rest.issues.createComment({
...ownerRepo,
issue_number: number,
body: closeMessage,
});
}
await octokit.rest.issues.createComment({
...ownerRepo,
issue_number: number,
body: closeMessage,
});

await octokit.rest.issues.update({
...ownerRepo,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/get-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface Config {
ownerRepo: { owner: string; repo: string };
staleLabel: string;
daysBeforeClose: number;
closeMessage: string | null;
closeMessage: string;
dryRun: boolean;
}

Expand Down Expand Up @@ -52,7 +52,7 @@ export async function getConfig(): Promise<Config> {
throw new TypeError('"days-before-close" must be a number');
}

const closeMessage = core.getInput('close-message') || null;
const closeMessage = core.getInput('close-message');

return {
octokit,
Expand Down

0 comments on commit 4558b9c

Please sign in to comment.