auto-label and fix pr template

This commit is contained in:
titus
2026-01-28 11:03:00 -06:00
parent 59a9c59064
commit 2dcfc2b109
2 changed files with 47 additions and 5 deletions

44
.github/workflows/label-pr.yaml vendored Normal file
View File

@@ -0,0 +1,44 @@
name: Label PRs by Type of Change
on:
pull_request:
types: [opened, edited, synchronize]
jobs:
label-pr:
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
steps:
- name: Check PR body for Type of Change
uses: actions/github-script@v7
with:
script: |
const prBody = context.payload.pull_request.body || '';
const labelsToAdd = [];
if (/\[x\]\s*New feature/i.test(prBody)) {
labelsToAdd.push('new feature');
}
if (/\[x\]\s*Bug fix/i.test(prBody)) {
labelsToAdd.push('bug');
}
if (/\[x\]\s*Documentation update/i.test(prBody)) {
labelsToAdd.push('documentation');
}
if (/\[x\]\s*Hotfix/i.test(prBody)) {
labelsToAdd.push('hotfix');
}
if (/\[x\]\s*UI\/UX improvement/i.test(prBody)) {
labelsToAdd.push('ui update');
}
if (labelsToAdd.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: labelsToAdd
});
}