From 9420b44c86a9271d0d9f107360501a058533f9e2 Mon Sep 17 00:00:00 2001 From: Yu-Ting Hsiung Date: Fri, 23 May 2025 16:55:07 +0800 Subject: [PATCH] docs(label_pr.yml): add labels based on new PR title --- .github/workflows/label_pr.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/label_pr.yml b/.github/workflows/label_pr.yml index b409c8b757..176d7cc794 100644 --- a/.github/workflows/label_pr.yml +++ b/.github/workflows/label_pr.yml @@ -17,3 +17,31 @@ jobs: - uses: actions/labeler@v5 with: configuration-path: .github/labeler.yml + - name: Label based on PR title + uses: actions/github-script@v7 + with: + script: | + const title = context.payload.pull_request.title.toLowerCase(); + const labels = []; + + if (title.includes("fix") || title.includes("bug")) { + labels.push("type: bug"); + } + if (title.includes("feat")) { + labels.push("type: feature"); + } + if (title.includes("doc")) { + labels.push("type: documentation"); + } + if (title.includes("refactor")) { + labels.push("type: refactor"); + } + + if (labels.length > 0) { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + labels + }); + }