Skip to content

Issue — Auto-close on No Response #51

Issue — Auto-close on No Response

Issue — Auto-close on No Response #51

Workflow file for this run

name: Issue — Auto-close on No Response
on:
schedule:
- cron: '0 */6 * * *'
workflow_dispatch:
jobs:
close-unresponded:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Close issues with no author response after 24h
uses: actions/github-script@v7
with:
script: |
const now = Date.now();
const twentyFourHours = 24 * 60 * 60 * 1000;
const issues = await github.paginate(
github.rest.issues.listForRepo,
{
owner: context.repo.owner,
repo: context.repo.repo,
state: "open",
labels: "waiting-on-author",
per_page: 100
}
);
for (const issue of issues) {
if (issue.pull_request) continue;
const openedAt = new Date(issue.created_at).getTime();
if (now - openedAt < twentyFourHours) continue;
const author = issue.user.login;
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
per_page: 100
});
const authorReplied = comments.data.some(c =>
c.user.login === author &&
new Date(c.created_at).getTime() > openedAt
);
if (authorReplied) {
try {
await github.rest.issues.removeLabel({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, name: "waiting-on-author" });
await github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, labels: ["in-progress"] });
} catch (e) {}
continue;
}
const closeBody = [
`Hey @${author} — this issue has been automatically closed because no additional information was received within **24 hours**.`,
``,
`This is not a rejection. If you still have the problem, please **reopen this issue** and include:`,
``,
`- The relevant log lines from your \`log.txt\``,
` - Location: \`Documents/My Games/FarmingSimulator2025/log.txt\``,
`- Your mod version (visible in the mod manager)`,
`- Steps to reproduce the issue`,
``,
`Without a log snippet it is very difficult to investigate issues. We look forward to helping you once we have the details!`,
].join("\n");
await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, body: closeBody });
await github.rest.issues.update({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issue.number, state: "closed", state_reason: "not_planned" });
core.info(`Closed issue #${issue.number} — no author response in 24h`);
}