mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
Automatically add category labels (e.g. `C-enhancement`) to PRs based on the conventional commit type (e.g. `feat`) used in their title.
84 lines
1.9 KiB
YAML
84 lines
1.9 KiB
YAML
name: Check PR
|
|
|
|
on:
|
|
pull_request_target:
|
|
types:
|
|
- opened
|
|
- edited
|
|
- synchronize
|
|
|
|
jobs:
|
|
pr:
|
|
if: github.repository == 'oxc-project/oxc'
|
|
name: Label and Check PR Title
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: taiki-e/checkout-action@v1
|
|
|
|
- uses: actions/labeler@v5
|
|
|
|
- name: Validate PR title
|
|
id: pr-title
|
|
uses: amannn/action-semantic-pull-request@v5
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
requireScope: true
|
|
disallowScopes: |
|
|
build
|
|
chore
|
|
ci
|
|
release
|
|
revert
|
|
types: |
|
|
build
|
|
chore
|
|
ci
|
|
docs
|
|
feat
|
|
fix
|
|
perf
|
|
refactor
|
|
release
|
|
revert
|
|
style
|
|
test
|
|
|
|
- name: Get category label from PR title
|
|
id: get-category
|
|
env:
|
|
PR_TYPE: ${{ steps.pr-title.outputs.type }}
|
|
run: |
|
|
case "$PR_TYPE" in
|
|
"feat")
|
|
CATEGORY="C-enhancement"
|
|
;;
|
|
"fix")
|
|
CATEGORY="C-bug"
|
|
;;
|
|
"test")
|
|
CATEGORY="C-test"
|
|
;;
|
|
"refactor" | "chore" | "style")
|
|
CATEGORY="C-cleanup"
|
|
;;
|
|
"docs")
|
|
CATEGORY="C-docs"
|
|
;;
|
|
"perf")
|
|
CATEGORY="C-performance"
|
|
;;
|
|
*)
|
|
CATEGORY=""
|
|
;;
|
|
esac
|
|
echo "CATEGORY=$CATEGORY" >> $GITHUB_OUTPUT
|
|
|
|
- name: Add category label
|
|
uses: actions-ecosystem/action-add-labels@v1
|
|
if: ${{ steps.get-category.outputs.CATEGORY != '' }}
|
|
with:
|
|
labels: ${{ steps.get-category.outputs.CATEGORY }}
|