GIT: workflows - auto close no template

Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
jokob-sk
2026-01-27 12:52:21 +11:00
parent 19b40de1de
commit 3d82af8cbc
8 changed files with 112 additions and 6 deletions

8
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -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.

View File

@@ -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: |
<!-- NETALERTX_TEMPLATE -->
- type: checkboxes
attributes:
label: Is there an existing issue for this?

View File

@@ -2,6 +2,10 @@ name: Feature Request
description: 'Suggest an idea for NetAlertX'
labels: ['Feature request ']
body:
- type: markdown
attributes:
value: |
<!-- NETALERTX_TEMPLATE -->
- type: checkboxes
attributes:
label: Is there an existing issue for this?

View File

@@ -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: |
<!-- NETALERTX_TEMPLATE -->
- type: dropdown
id: installation_type
attributes:

View File

@@ -2,12 +2,16 @@ name: Security Report 🔐
description: Report a security vulnerability or concern privately.
labels: ['security 🔐']
body:
- type: markdown
attributes:
value: |
<!-- NETALERTX_TEMPLATE -->
- 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:

View File

@@ -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: |
<!-- NETALERTX_TEMPLATE -->
- type: dropdown
id: installation_type
attributes:

69
.github/workflows/enforce-template.yml vendored Normal file
View File

@@ -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.");

View File

@@ -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(", ")}`);
}