From 3d82af8cbc2ce7f891c4122200094352845e20cb Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Tue, 27 Jan 2026 12:52:21 +1100 Subject: [PATCH] GIT: workflows - auto close no template Signed-off-by: jokob-sk --- .github/ISSUE_TEMPLATE/config.yml | 8 +++ .../ISSUE_TEMPLATE/documentation-feedback.yml | 4 ++ .github/ISSUE_TEMPLATE/feature_request.yml | 4 ++ .github/ISSUE_TEMPLATE/i-have-an-issue.yml | 4 ++ .github/ISSUE_TEMPLATE/security-report.yml | 6 +- .github/ISSUE_TEMPLATE/setup-help.yml | 4 ++ .github/workflows/enforce-template.yml | 69 +++++++++++++++++++ .github/workflows/label-issues.yml | 19 +++-- 8 files changed, 112 insertions(+), 6 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/workflows/enforce-template.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..c315bc81 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: 💬 Discussions + url: https://github.com/netalertx/NetAlertX/discussions + about: Ask questions or start discussions here. + - name: 🗯 Discord + url: https://discord.com/invite/NczTUTWyRr + about: Ask the community for help. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/documentation-feedback.yml b/.github/ISSUE_TEMPLATE/documentation-feedback.yml index fac8b58a..6c25a8e4 100755 --- a/.github/ISSUE_TEMPLATE/documentation-feedback.yml +++ b/.github/ISSUE_TEMPLATE/documentation-feedback.yml @@ -2,6 +2,10 @@ name: Documentation Feedback 📝 description: Suggest improvements, clarify inconsistencies, or report issues related to the documentation. labels: ['documentation 📚'] body: +- type: markdown + attributes: + value: | + - type: checkboxes attributes: label: Is there an existing issue for this? diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 8ee485c3..8442e274 100755 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -2,6 +2,10 @@ name: Feature Request description: 'Suggest an idea for NetAlertX' labels: ['Feature request ➕'] body: +- type: markdown + attributes: + value: | + - type: checkboxes attributes: label: Is there an existing issue for this? diff --git a/.github/ISSUE_TEMPLATE/i-have-an-issue.yml b/.github/ISSUE_TEMPLATE/i-have-an-issue.yml index 63bbe77d..4d5fa229 100755 --- a/.github/ISSUE_TEMPLATE/i-have-an-issue.yml +++ b/.github/ISSUE_TEMPLATE/i-have-an-issue.yml @@ -2,6 +2,10 @@ name: Bug Report description: 'When submitting an issue enable LOG_LEVEL="trace" and have a look at the docs.' labels: ['bug 🐛'] body: +- type: markdown + attributes: + value: | + - type: dropdown id: installation_type attributes: diff --git a/.github/ISSUE_TEMPLATE/security-report.yml b/.github/ISSUE_TEMPLATE/security-report.yml index 6653dd92..16040670 100755 --- a/.github/ISSUE_TEMPLATE/security-report.yml +++ b/.github/ISSUE_TEMPLATE/security-report.yml @@ -2,12 +2,16 @@ name: Security Report 🔐 description: Report a security vulnerability or concern privately. labels: ['security 🔐'] body: +- type: markdown + attributes: + value: | + - type: markdown attributes: value: | **Important:** For security reasons, please do **not** post sensitive security issues publicly in the issue tracker. Instead, send details to our security contact email: [jokob@duck.com](mailto:jokob@duck.com). - + We appreciate your responsible disclosure. - type: textarea attributes: diff --git a/.github/ISSUE_TEMPLATE/setup-help.yml b/.github/ISSUE_TEMPLATE/setup-help.yml index 44ac630e..b47907f8 100755 --- a/.github/ISSUE_TEMPLATE/setup-help.yml +++ b/.github/ISSUE_TEMPLATE/setup-help.yml @@ -2,6 +2,10 @@ name: Setup help description: 'When submitting an issue enable LOG_LEVEL="trace" and re-search first.' labels: ['Setup 📥'] body: +- type: markdown + attributes: + value: | + - type: dropdown id: installation_type attributes: diff --git a/.github/workflows/enforce-template.yml b/.github/workflows/enforce-template.yml new file mode 100644 index 00000000..ffa9c2b8 --- /dev/null +++ b/.github/workflows/enforce-template.yml @@ -0,0 +1,69 @@ +name: Enforce Issue Templates + +on: + issues: + types: [opened] + +permissions: + issues: write + +jobs: + enforce-template: + runs-on: ubuntu-latest + steps: + - name: Check for template usage + uses: actions/github-script@v7 + with: + script: | + const body = (context.payload.issue.body || "").toLowerCase(); + const title = (context.payload.issue.title || "").toLowerCase(); + + // 1. Check for template marker + const usedTemplate = body.includes('netalertx_template'); + + // 2. Security Bypass: Don't close if it looks like a security report + const isSecurity = title.includes('security') || title.includes('vulnerability'); + + if (!usedTemplate && !isSecurity) { + const warningLabel = 'missing-template 📋'; + + // Add descriptive label + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: [warningLabel] + }); + + // Post polite comment with direct link to new issue + const commentMessage = ` + Hi there! 👋 Thanks for reaching out. + + To help the maintainers triage issues effectively, we **enforce the use of issue templates**. This helps us resolve problems much faster! + + **This issue has been closed** because it is missing the required template. + + Please [open a new issue here](https://github.com/${context.repo.owner}/${context.repo.repo}/issues/new/choose) and select the appropriate template. + + Thank you for your understanding! 🙏 + `; + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: commentMessage + }); + + // Close the issue (but do NOT lock it) + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + state: 'closed' + }); + + return; + } + + console.log("Template detected or security keyword found ✅. Proceeding."); \ No newline at end of file diff --git a/.github/workflows/label-issues.yml b/.github/workflows/label-issues.yml index c7606423..65e2e66a 100755 --- a/.github/workflows/label-issues.yml +++ b/.github/workflows/label-issues.yml @@ -15,21 +15,28 @@ jobs: uses: actions/github-script@v7 with: script: | - const body = context.payload.issue.body; + const body = (context.payload.issue.body || "").toLowerCase(); - const lowerBody = body.toLowerCase(); + // --- Check for template marker --- + const hasTemplate = body.includes('netalertx_template'); + if (!hasTemplate) { + console.log("No template marker found, skipping labeling."); + return; // skip labeling + } + + // --- Proceed with normal labeling --- let labelsToAdd = []; - if (lowerBody.includes('bare-metal') || lowerBody.includes('proxmox')) { + if (body.includes('bare-metal') || body.includes('proxmox')) { labelsToAdd.push('bare-metal ❗'); } - if (lowerBody.includes('home assistant')) { + if (body.includes('home assistant')) { labelsToAdd.push('Home Assistant 🏠'); } - if (lowerBody.includes('production (netalertx)') || lowerBody.includes('dev (netalertx-dev)')) { + if (body.includes('production (netalertx)') || body.includes('dev (netalertx-dev)')) { labelsToAdd.push('Docker 🐋'); } @@ -40,4 +47,6 @@ jobs: issue_number: context.issue.number, labels: labelsToAdd }); + + console.log(`Added labels: ${labelsToAdd.join(", ")}`); }