- Add PR template with description, type of change, and contributing checklist - Enforce target branch: label + comment + 24h auto-close for PRs targeting main - Flag bad issue titles: label + comment + 24h auto-close instead of instant close - Redirect feature requests to Discussions (instant close, unchanged) - Add two scheduled workflows to close stale labeled issues and PRs after 24h - Update CONTRIBUTING.md with tests and branch up-to-date requirements
72 lines
2.3 KiB
YAML
72 lines
2.3 KiB
YAML
name: Close issues with unchanged bad titles
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 */6 * * *' # Every 6 hours
|
|
|
|
permissions:
|
|
issues: write
|
|
|
|
jobs:
|
|
close-stale:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Close stale invalid-title issues
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const badTitles = [
|
|
"[bug]", "bug report", "bug", "issue",
|
|
"help", "question", "test", "...", "untitled"
|
|
];
|
|
|
|
const { data: issues } = await github.rest.issues.listForRepo({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
labels: 'invalid-title',
|
|
state: 'open',
|
|
per_page: 100,
|
|
});
|
|
|
|
const twentyFourHoursAgo = new Date(Date.now() - 24 * 60 * 60 * 1000);
|
|
|
|
for (const issue of issues) {
|
|
const createdAt = new Date(issue.created_at);
|
|
if (createdAt > twentyFourHoursAgo) continue; // grace period not over yet
|
|
|
|
const titleLower = issue.title.trim().toLowerCase();
|
|
|
|
if (!badTitles.includes(titleLower)) {
|
|
// Title was fixed — remove the label and move on
|
|
await github.rest.issues.removeLabel({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: issue.number,
|
|
name: 'invalid-title',
|
|
});
|
|
continue;
|
|
}
|
|
|
|
// Still a bad title after 24h — close it
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: issue.number,
|
|
body: [
|
|
'## Issue closed',
|
|
'',
|
|
'This issue has been automatically closed because the title was not updated within 24 hours.',
|
|
'',
|
|
'Feel free to open a new issue with a descriptive title that summarizes the problem.',
|
|
].join('\n'),
|
|
});
|
|
|
|
await github.rest.issues.update({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: issue.number,
|
|
state: 'closed',
|
|
state_reason: 'not_planned',
|
|
});
|
|
}
|