]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Chore: improve PR labeling move all labelling to pr-bot workflow (#9970)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Mon, 19 May 2025 20:44:25 +0000 (13:44 -0700)
committerGitHub <noreply@github.com>
Mon, 19 May 2025 20:44:25 +0000 (13:44 -0700)
.github/labeler.yml
.github/release-drafter.yml
.github/workflows/pr-bot.yml

index bd2af861147c56556949185c6e9c83bb61e33565..7587db1b4d981ebdf1429334f85d5cfc42c3333f 100644 (file)
@@ -17,3 +17,10 @@ ci-cd:
   - changed-files:
       - any-glob-to-any-file:
           - '.github/**'
+# pr types
+bug:
+  - head-branch:
+      - ['^fix']
+enhancement:
+  - head-branch:
+      - ['^feature']
index cb48d4ba0523220567977d9b4e5b28e4f21912de..89c8a96eaec40afa74183fadbf9b6b4a92b1e6f8 100644 (file)
@@ -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'
index 1df96c1261f73ce77aa19097bcc8528e2d9b8c28..8a394e9c7c64c197b1a420a2d3ddf36323b041f9 100644 (file)
@@ -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