add auto-close-issues workflow

This commit is contained in:
tiago
2025-12-20 13:11:03 +00:00
committed by GitHub
parent 83e0248411
commit f29bde8a0d
+37
View File
@@ -0,0 +1,37 @@
name: Auto-close empty issues
on:
issues:
types: [opened]
permissions:
issues: write
jobs:
close:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
const title = context.payload.issue.title?.trim()
const body = context.payload.issue.body ?? ""
const badTitle = title === "[BUG]"
const badBody = body.includes("A clear and concise description of what the bug is.")
if (badTitle && badBody) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
state: "closed"
})
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
body: "This issue has been automatically closed due to it being empty. If this isn't intentional, please re-open it with a proper title and body."
})
}