Skip to content

Commit

Permalink
Merge pull request #1460 from nichwall/close_blank_issue
Browse files Browse the repository at this point in the history
Add: workflow to close issues without template
  • Loading branch information
advplyr authored Jan 29, 2025
2 parents 3d0c064 + 50755ea commit fa6b71a
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/close_blank_issues.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Close Issues not using a template

on:
issues:
types:
- opened

permissions:
issues: write

jobs:
close_issue:
runs-on: ubuntu-latest

steps:
- name: Check issue headings
uses: actions/github-script@v6
with:
script: |
const issueBody = context.payload.issue.body || "";
// Match Markdown headings (e.g., # Heading, ## Heading)
const headingRegex = /^(#{1,6})\s.+/gm;
const headings = [...issueBody.matchAll(headingRegex)];
if (headings.length < 3) {
// Post a comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
body: "Thank you for opening an issue! To help us review your request efficiently, please use one of the provided issue templates. If you're seeking information or have a general question, consider opening a Discussion or joining the conversation on our Discord. Thanks!"
});
// Close the issue
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
state: "closed"
});
}

0 comments on commit fa6b71a

Please sign in to comment.