From 2dcfc2b1092a8b40a58a3d86c668ec23c61042f1 Mon Sep 17 00:00:00 2001 From: titus Date: Wed, 28 Jan 2026 11:03:00 -0600 Subject: [PATCH] auto-label and fix pr template --- .github/PULL_REQUEST_TEMPLATE.md | 8 +++--- .github/workflows/label-pr.yaml | 44 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/label-pr.yaml diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 50f6b023..8fc9d3d0 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,11 +4,11 @@ - [ ] New feature - [ ] Bug fix - [ ] Documentation update -- [ ] Refactoring - [ ] Hotfix -- [ ] Security patch - [ ] UI/UX improvement + + ## Description @@ -18,7 +18,5 @@ ## Checklist - [ ] My code adheres to the coding and style guidelines of the project. -- [ ] I have performed a self-review of my own code. - [ ] I have commented my code, particularly in hard-to-understand areas. -- [ ] I have made corresponding changes to the documentation. -- [ ] My changes generate no errors/warnings/merge conflicts. +- [ ] I have made corresponding changes to the documentation. \ No newline at end of file diff --git a/.github/workflows/label-pr.yaml b/.github/workflows/label-pr.yaml new file mode 100644 index 00000000..397c6585 --- /dev/null +++ b/.github/workflows/label-pr.yaml @@ -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 + }); + } \ No newline at end of file