From e092627da6ff7ded5bad2f9575e6e798a2650159 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 19 May 2025 13:44:25 -0700 Subject: [PATCH] Chore: improve PR labeling move all labelling to pr-bot workflow (#9970) --- .github/labeler.yml | 7 +++++++ .github/release-drafter.yml | 14 +------------- .github/workflows/pr-bot.yml | 28 +++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index bd2af8611..7587db1b4 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -17,3 +17,10 @@ ci-cd: - changed-files: - any-glob-to-any-file: - '.github/**' +# pr types +bug: + - head-branch: + - ['^fix'] +enhancement: + - head-branch: + - ['^feature'] diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index cb48d4ba0..89c8a96ea 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,15 +1,3 @@ -autolabeler: - - label: "bug" - branch: - - '/^fix/' - title: - - "/^fix/i" - - "/^Bugfix/i" - - label: "enhancement" - branch: - - '/^feature/' - title: - - "/^feature/i" categories: - title: 'Breaking Changes' labels: @@ -17,7 +5,7 @@ categories: - title: 'Notable Changes' labels: - 'notable' - - title: 'Features' + - title: 'Features / Enhancements' labels: - 'enhancement' - title: 'Bug Fixes' diff --git a/.github/workflows/pr-bot.yml b/.github/workflows/pr-bot.yml index 1df96c126..8a394e9c7 100644 --- a/.github/workflows/pr-bot.yml +++ b/.github/workflows/pr-bot.yml @@ -10,7 +10,8 @@ jobs: name: Automated PR Bot runs-on: ubuntu-latest steps: - - name: Label by file path + - name: Label PR by file path or branch name + # see .github/labeler.yml for the labeler config uses: actions/labeler@v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} @@ -24,6 +25,31 @@ jobs: s_diff: '99999' fail_if_xl: 'false' excluded_files: /\.lock$/ /\.txt$/ ^src-ui/pnpm-lock\.yaml$ ^src-ui/messages\.xlf$ ^src/locale/en_US/LC_MESSAGES/django\.po$ + - name: Label by PR title + uses: actions/github-script@v7 + with: + script: | + const pr = context.payload.pull_request; + const title = pr.title.toLowerCase(); + const labels = []; + + if (/^(fix|bugfix)/i.test(title)) { + labels.push('bug'); + } else if (/^feature/i.test(title)) { + labels.push('enhancement'); + } else { + labels.push('enhancement'); // Default fallback + } + + if (labels.length) { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + labels, + }); + core.info(`Added labels based on title: ${labels.join(', ')}`); + } - name: Label bot-generated PRs if: ${{ contains(github.actor, 'dependabot') || contains(github.actor, 'crowdin-bot') }} uses: actions/github-script@v7