Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/workflows/close-mistake-issues.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Close Mistake Issues

on:
issues:
types: [opened]

jobs:
check-mistake-issue:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Check if issue is a mistake
id: check
uses: actions/github-script@v7
with:
script: |
const issue = context.payload.issue;
const title = issue.title.trim();
const body = (issue.body || '').trim();

// Patterns that indicate a mistake issue:
// 1. Title is just a URL (especially git URLs)
// 2. Title contains .git with minimal body
// 3. Title contains placeholder text like "TYPE YOUR QUESTION HERE"

const containsGit = title.includes('.git');
const isShortBody = body.length < 20;
const isJustUrl = /^https?:\/\/[^\s]+$/.test(title);

// Check for common placeholder patterns in the title
const placeholderPatterns = [
/TYPE YOUR QUESTION HERE/i,
/TYPE YOUR ISSUE HERE/i,
/ENTER YOUR TITLE HERE/i,
/YOUR TITLE HERE/i,
/\[INSERT TITLE\]/i,
/\[YOUR TITLE\]/i
];
const hasPlaceholderTitle = placeholderPatterns.some(
pattern => pattern.test(title)
);

// Check if body is mostly template text
const templateIndicators = [
'Please describe',
'*Please describe',
'TYPE YOUR',
'Reported from:'
];
const bodyWithoutTemplate = body.split('\n')
.filter(line => !templateIndicators.some(
indicator => line.includes(indicator)
))
.join('\n')
.trim();
const isTemplateBody = bodyWithoutTemplate.length < 20;

// Consider it a mistake if:
// - Title is just a URL, or
// - Title contains .git and body is very short/empty, or
// - Title has placeholder text and body is mostly template
const isMistake = isJustUrl ||
(containsGit && isShortBody) ||
(hasPlaceholderTitle && isTemplateBody);

if (isMistake) {
console.log('Issue appears to be opened by mistake');
console.log(`Title: ${title}`);
console.log(`Body length: ${body.length}`);

// Close the issue with a comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: 'Appears to have been opened by mistake.'
});

await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: 'closed'
});

console.log('Issue closed');
} else {
console.log('Issue appears to be legitimate');
}