This is an automated email from the ASF dual-hosted git repository.

mridulpathak pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 8286d1d3dd Improved: Set the release_branch label of pull requests 
automatically (OFBIZ-13696)
8286d1d3dd is described below

commit 8286d1d3dd0f28de07b3e7c97be4c1a141db0381
Author: Mridul Pathak <[email protected]>
AuthorDate: Sun Oct 18 11:05:33 2026 +0530

    Improved: Set the release_branch label of pull requests automatically 
(OFBIZ-13696)
    
    - Dependabot adds the release_branch label to its pull requests to 
release24.09, besides the dependencies and ecosystem labels it adds by default.
    - The PR Labels workflow, renamed from PR Type Label since it now sets more 
than the type label, adds the release_branch label to the other pull requests 
to a release branch, removes it if a pull request is retargeted to trunk, and 
adds it when run manually to the pull requests already merged.
    - Document both in .github/README-CI-CD.md, including the labels to give 
the Dependabot entries of a new release branch.
---
 .github/README-CI-CD.md             |  6 ++++--
 .github/dependabot.yml              | 16 ++++++++++++++++
 .github/workflows/pr-type-label.yml | 30 +++++++++++++++++++-----------
 3 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/.github/README-CI-CD.md b/.github/README-CI-CD.md
index 30a7bddc2e..e4a1ff6f1a 100644
--- a/.github/README-CI-CD.md
+++ b/.github/README-CI-CD.md
@@ -27,8 +27,8 @@
   → Trigger: push / PR on `.github/` path
 
 - `pr-type-label.yml`
-  Sets the type label (`bug`, `enhancement`, `feature`, `documentation`) of a 
PR from its title prefix (Fixed, Improved, Implemented, Documented), so that 
`release.yml` can group the release notes, and the `dependencies` label to the 
PRs titled "Bump ..."
-  → Trigger: PR opened, reopened or retitled on `trunk` and `release*` + 
manual run to label merged PRs
+  Sets the type label (`bug`, `enhancement`, `feature`, `documentation`) of a 
PR from its title prefix (Fixed, Improved, Implemented, Documented), so that 
`release.yml` can group the release notes, and the `dependencies` label to the 
PRs titled "Bump ...", and the `release_branch` label to the PRs to a 
`release*` branch (removed if a PR is retargeted to `trunk`)
+  → Trigger: PR opened, reopened, retitled or retargeted on `trunk` and 
`release*` + manual run to label merged PRs
 
 ### Workflow behavior
 
@@ -73,6 +73,8 @@ Before creating a new release branch from `trunk`, update 
`dependabot.yml` (on `
 - github-actions
 - docker
 
+Give each of these entries the `labels` of the existing release branch entries 
(`dependencies`, the ecosystem label and `release_branch`).
+
 Then create the release branch.
 
 Dependabot will automatically keep the new branch up to date.
\ No newline at end of file
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 5a0544caa3..eacd5b87b8 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -37,6 +37,10 @@ updates:
   - package-ecosystem: "gradle"
     directory: "/"
     target-branch: "release24.09"
+    labels:
+      - "dependencies"
+      - "java"
+      - "release_branch"
     schedule:
       interval: "daily"
     open-pull-requests-limit: 40
@@ -74,6 +78,10 @@ updates:
   - package-ecosystem: "npm"
     directory: "themes/common-theme/webapp/common-theme/js"
     target-branch: "release24.09"
+    labels:
+      - "dependencies"
+      - "javascript"
+      - "release_branch"
     schedule:
       interval: "daily"
     open-pull-requests-limit: 20
@@ -91,6 +99,10 @@ updates:
   - package-ecosystem: github-actions
     directory: /
     target-branch: "release24.09"
+    labels:
+      - "dependencies"
+      - "github_actions"
+      - "release_branch"
     schedule:
       interval: daily
     groups:
@@ -107,5 +119,9 @@ updates:
   - package-ecosystem: docker
     directory: /
     target-branch: "release24.09"
+    labels:
+      - "dependencies"
+      - "docker"
+      - "release_branch"
     schedule:
       interval: daily
diff --git a/.github/workflows/pr-type-label.yml 
b/.github/workflows/pr-type-label.yml
index f3b584329c..cbdd772f0e 100644
--- a/.github/workflows/pr-type-label.yml
+++ b/.github/workflows/pr-type-label.yml
@@ -22,10 +22,11 @@
 # generates (see .github/release.yml) can group pull requests by type.
 # Dependency updates titled "Bump ..." get the dependencies label, which
 # leaves them out of the release notes like the Dependabot pull requests.
+# Pull requests to a release branch get the release_branch label.
 # It never checks out nor runs code of the pull request.
 # Run it manually (workflow_dispatch) to label pull requests already merged.
 
-name: "PR Type Label"
+name: "PR Labels"
 
 on:
   pull_request_target:
@@ -52,7 +53,7 @@ jobs:
     if: >-
       github.event_name == 'workflow_dispatch' ||
       (github.event.pull_request.user.login != 'dependabot[bot]' &&
-       (github.event.action != 'edited' || github.event.changes.title))
+       (github.event.action != 'edited' || github.event.changes.title || 
github.event.changes.base))
     runs-on: ubuntu-latest
     permissions:
       pull-requests: write
@@ -62,6 +63,7 @@ jobs:
         with:
           script: |
             const TYPE_LABELS = ['bug', 'enhancement', 'feature', 
'documentation'];
+            const RELEASE_BRANCH_LABEL = 'release_branch';
             const PREFIXES = [
               [/^(fixed|fix|fixing)(?=[\s:])/i, 'bug'],
               [/^(improved|completed)(?=[\s:])/i, 'enhancement'],
@@ -108,27 +110,33 @@ jobs:
               }
             }
 
-            async function setTypeLabel(pr, dryRun) {
+            async function setLabels(pr, dryRun) {
               const label = await typeLabel(pr);
               const current = pr.labels.map(l => l.name);
-              const stale = label ? current.filter(name => 
TYPE_LABELS.includes(name) && name !== label) : [];
-              const add = label && !current.includes(label);
-              core.info(`#${pr.number} [${label || 'no type'}]${stale.length ? 
` -${stale.join(' -')}` : ''}${add ? ` +${label}` : ''} ${pr.title}`);
+              const remove = label ? current.filter(name => 
TYPE_LABELS.includes(name) && name !== label) : [];
+              const add = label && !current.includes(label) ? [label] : [];
+              const onReleaseBranch = pr.base.ref.startsWith('release');
+              if (onReleaseBranch && !current.includes(RELEASE_BRANCH_LABEL)) {
+                add.push(RELEASE_BRANCH_LABEL);
+              } else if (pr.base.ref === pr.base.repo.default_branch && 
current.includes(RELEASE_BRANCH_LABEL)) {
+                remove.push(RELEASE_BRANCH_LABEL);
+              }
+              core.info(`#${pr.number} [${label || 'no 
type'}]${remove.map(name => ` -${name}`).join('')}${add.map(name => ` 
+${name}`).join('')} ${pr.title}`);
               if (dryRun) {
                 return;
               }
-              for (const name of stale) {
+              for (const name of remove) {
                 await github.rest.issues.removeLabel({ owner, repo, 
issue_number: pr.number, name });
               }
-              if (add) {
-                await github.rest.issues.addLabels({ owner, repo, 
issue_number: pr.number, labels: [label] });
+              if (add.length) {
+                await github.rest.issues.addLabels({ owner, repo, 
issue_number: pr.number, labels: add });
               }
             }
 
             if (context.eventName === 'pull_request_target') {
               // read the pull request again, a previous run may have changed 
its labels
               const { data: pr } = await github.rest.pulls.get({ owner, repo, 
pull_number: context.payload.pull_request.number });
-              await setTypeLabel(pr, false);
+              await setLabels(pr, false);
               return;
             }
 
@@ -150,5 +158,5 @@ jobs:
               });
             core.info(`${merged.length} pull requests merged since 
${since}${dryRun ? ' (dry run)' : ''}`);
             for (const pr of merged) {
-              await setTypeLabel(pr, dryRun);
+              await setLabels(pr, dryRun);
             }

Reply via email to