Files
semantica/.github/workflows/label-issues.yml
T
Workflow config file is invalid. Please check your config file: resolve aliases: yaml: line 89: did not find expected key
KaifAhmad1 1271957737 security: Add explicit permissions and security scanning workflow
- Add explicit permissions to all workflows (format, release, ci, test, label-issues, mark-answered)
- Fix format.yml to have write permissions for PR creation
- Add security.yml workflow for automated vulnerability scanning
- Improve security posture with minimal permissions principle
2025-11-24 17:20:10 +05:30

105 lines
3.6 KiB
YAML

name: Auto-label Issues
# Automatically labels new issues based on content
# Provides help resources when requested
on:
issues:
types: [opened]
issue_comment:
types: [created]
permissions:
contents: read
issues: write
pull-requests: read
jobs:
label:
name: Auto-label Issues
runs-on: ubuntu-latest
if: github.event.action == 'opened'
steps:
- name: Add labels based on content
uses: actions/github-script@v7
with:
script: |
const issue = context.payload.issue;
const title = issue.title.toLowerCase();
const body = (issue.body || '').toLowerCase();
const text = title + ' ' + body;
const labels = [];
// Bug detection
if ((text.match(/\b(bug|crash|broken|fails|doesn't work|not working)\b/) &&
text.match(/\b(error|exception|traceback|problem)\b/)) ||
title.startsWith('bug:') || title.startsWith('[bug]')) {
labels.push('bug');
}
// Feature request
else if (text.match(/\b(feature request|enhancement request|proposal)\b/) ||
title.startsWith('feature:') || title.startsWith('[feature]') ||
title.startsWith('enhancement:') || title.startsWith('[enhancement]')) {
labels.push('enhancement');
}
// Documentation
else if (text.match(/\b(documentation issue|doc fix|docs update)\b/) ||
title.startsWith('docs:') || title.startsWith('[docs]')) {
labels.push('documentation');
}
// Security
else if (text.match(/\b(security issue|vulnerability|security bug)\b/) ||
title.startsWith('security:') || title.startsWith('[security]')) {
labels.push('security');
}
// Needs triage for incomplete issues
if (labels.length === 0 && (body.length < 50 || !body.includes('\n'))) {
labels.push('needs-triage');
}
// Add labels if found
if (labels.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: labels
});
}
help:
name: Provide Help Resources
runs-on: ubuntu-latest
if: |
github.event.action == 'opened' &&
(contains(github.event.issue.body, '/help') || contains(github.event.issue.title, '/help'))
steps:
- name: Post help resources
uses: actions/github-script@v7
with:
script: |
const response = `📚 **Help Resources**
Here are some helpful resources:
- [Getting Started](https://github.com/${{ github.repository }}/blob/main/docs/getting-started.md)
- [FAQ](https://github.com/${{ github.repository }}/blob/main/docs/faq.md)
- [Documentation](https://github.com/${{ github.repository }}/tree/main/docs)
- [GitHub Discussions](https://github.com/${{ github.repository }}/discussions) - Ask questions here
- [Discord](https://discord.gg/semantica) - Real-time chat
💡 **Tip**: For questions, consider using [GitHub Discussions](https://github.com/${{ github.repository }}/discussions) instead of issues.`;
await github.rest.issues.createComment({
issue_number: context.payload.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: response
});