🛠 Project Health & Improvement Checklist #18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Label Issues | |
| on: | |
| issues: | |
| types: [opened, edited] | |
| jobs: | |
| label: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| issues: write | |
| steps: | |
| - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const title = context.payload.issue.title.toLowerCase(); | |
| const body = (context.payload.issue.body || '').toLowerCase(); | |
| const text = title + ' ' + body; | |
| const labels = []; | |
| if (/\b(bug|error|crash|broken|fail|problem|not working)\b/.test(text)) { | |
| labels.push('bug'); | |
| } | |
| if (/\b(feature|enhancement|request|add|improve|suggest)\b/.test(text)) { | |
| labels.push('enhancement'); | |
| } | |
| if (/\b(doc|documentation|readme|guide|example)\b/.test(text)) { | |
| labels.push('documentation'); | |
| } | |
| if (/\b(question|help wanted)\b/.test(text) || /\bhow (to|do|does|can)\b/.test(text)) { | |
| labels.push('question'); | |
| } | |
| if (labels.length > 0) { | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.issue.number, | |
| labels: labels | |
| }); | |
| } |