mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-03-30 23:03:03 -07:00
GIT: workflows - auto close no template
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal 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.
|
||||||
@@ -2,6 +2,10 @@ name: Documentation Feedback 📝
|
|||||||
description: Suggest improvements, clarify inconsistencies, or report issues related to the documentation.
|
description: Suggest improvements, clarify inconsistencies, or report issues related to the documentation.
|
||||||
labels: ['documentation 📚']
|
labels: ['documentation 📚']
|
||||||
body:
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
<!-- NETALERTX_TEMPLATE -->
|
||||||
- type: checkboxes
|
- type: checkboxes
|
||||||
attributes:
|
attributes:
|
||||||
label: Is there an existing issue for this?
|
label: Is there an existing issue for this?
|
||||||
|
|||||||
4
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
4
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@@ -2,6 +2,10 @@ name: Feature Request
|
|||||||
description: 'Suggest an idea for NetAlertX'
|
description: 'Suggest an idea for NetAlertX'
|
||||||
labels: ['Feature request ➕']
|
labels: ['Feature request ➕']
|
||||||
body:
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
<!-- NETALERTX_TEMPLATE -->
|
||||||
- type: checkboxes
|
- type: checkboxes
|
||||||
attributes:
|
attributes:
|
||||||
label: Is there an existing issue for this?
|
label: Is there an existing issue for this?
|
||||||
|
|||||||
4
.github/ISSUE_TEMPLATE/i-have-an-issue.yml
vendored
4
.github/ISSUE_TEMPLATE/i-have-an-issue.yml
vendored
@@ -2,6 +2,10 @@ name: Bug Report
|
|||||||
description: 'When submitting an issue enable LOG_LEVEL="trace" and have a look at the docs.'
|
description: 'When submitting an issue enable LOG_LEVEL="trace" and have a look at the docs.'
|
||||||
labels: ['bug 🐛']
|
labels: ['bug 🐛']
|
||||||
body:
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
<!-- NETALERTX_TEMPLATE -->
|
||||||
- type: dropdown
|
- type: dropdown
|
||||||
id: installation_type
|
id: installation_type
|
||||||
attributes:
|
attributes:
|
||||||
|
|||||||
6
.github/ISSUE_TEMPLATE/security-report.yml
vendored
6
.github/ISSUE_TEMPLATE/security-report.yml
vendored
@@ -2,12 +2,16 @@ name: Security Report 🔐
|
|||||||
description: Report a security vulnerability or concern privately.
|
description: Report a security vulnerability or concern privately.
|
||||||
labels: ['security 🔐']
|
labels: ['security 🔐']
|
||||||
body:
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
<!-- NETALERTX_TEMPLATE -->
|
||||||
- type: markdown
|
- type: markdown
|
||||||
attributes:
|
attributes:
|
||||||
value: |
|
value: |
|
||||||
**Important:** For security reasons, please do **not** post sensitive security issues publicly in the issue tracker.
|
**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).
|
Instead, send details to our security contact email: [jokob@duck.com](mailto:jokob@duck.com).
|
||||||
|
|
||||||
We appreciate your responsible disclosure.
|
We appreciate your responsible disclosure.
|
||||||
- type: textarea
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
|
|||||||
4
.github/ISSUE_TEMPLATE/setup-help.yml
vendored
4
.github/ISSUE_TEMPLATE/setup-help.yml
vendored
@@ -2,6 +2,10 @@ name: Setup help
|
|||||||
description: 'When submitting an issue enable LOG_LEVEL="trace" and re-search first.'
|
description: 'When submitting an issue enable LOG_LEVEL="trace" and re-search first.'
|
||||||
labels: ['Setup 📥']
|
labels: ['Setup 📥']
|
||||||
body:
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
<!-- NETALERTX_TEMPLATE -->
|
||||||
- type: dropdown
|
- type: dropdown
|
||||||
id: installation_type
|
id: installation_type
|
||||||
attributes:
|
attributes:
|
||||||
|
|||||||
69
.github/workflows/enforce-template.yml
vendored
Normal file
69
.github/workflows/enforce-template.yml
vendored
Normal 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.");
|
||||||
19
.github/workflows/label-issues.yml
vendored
19
.github/workflows/label-issues.yml
vendored
@@ -15,21 +15,28 @@ jobs:
|
|||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
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 = [];
|
let labelsToAdd = [];
|
||||||
|
|
||||||
if (lowerBody.includes('bare-metal') || lowerBody.includes('proxmox')) {
|
if (body.includes('bare-metal') || body.includes('proxmox')) {
|
||||||
labelsToAdd.push('bare-metal ❗');
|
labelsToAdd.push('bare-metal ❗');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lowerBody.includes('home assistant')) {
|
if (body.includes('home assistant')) {
|
||||||
labelsToAdd.push('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 🐋');
|
labelsToAdd.push('Docker 🐋');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,4 +47,6 @@ jobs:
|
|||||||
issue_number: context.issue.number,
|
issue_number: context.issue.number,
|
||||||
labels: labelsToAdd
|
labels: labelsToAdd
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(`Added labels: ${labelsToAdd.join(", ")}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user