diff --git a/.github/workflows/update-stable-titles.yml b/.github/workflows/update-stable-titles.yml new file mode 100644 index 000000000..ca8be8bff --- /dev/null +++ b/.github/workflows/update-stable-titles.yml @@ -0,0 +1,71 @@ +# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT +name: Update PRs titles on stable branches + +on: + pull_request: + types: [opened, edited] + branches: + - "stable*" + +concurrency: + group: stable-pr-title-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + update-pr-title: + runs-on: ubuntu-latest-low + permissions: + pull-requests: write + contents: read + + steps: + - name: Wait for potential title edits + run: sleep 15 + + - name: Get PR details and update title + # Renovate already have target branch in the title + if: github.event.pull_request.user.login != 'renovate[bot]' + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { data: pr } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + }); + + const baseBranch = pr.base.ref; + const currentTitle = pr.title; + + // Check if this is a stable branch + // Should not happen as we only trigger on stable* branches 🤷‍♀️ + if (!baseBranch.startsWith('stable')) { + console.log(`Not a stable branch: ${baseBranch}`); + return; + } + + const prefix = `[${baseBranch}]`; + + // Check if title already has the correct prefix and no other stable tags + const correctTagRegex = new RegExp(`^\\[${baseBranch}\\]\\s*`); + const hasOtherStableTags = /\[stable[\d.]*\]/.test(currentTitle.replace(correctTagRegex, '')); + + if (correctTagRegex.test(currentTitle) && !hasOtherStableTags) { + console.log(`Title already has correct prefix only: ${currentTitle}`); + return; + } + + // Remove all stable tags and add the correct one + const cleanTitle = currentTitle.replace(/\[stable[\d.]*\]\s*/g, '').trim(); + const newTitle = `${prefix} ${cleanTitle}`; + + console.log(`Updating title from: "${currentTitle}" to: "${newTitle}"`); + + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + title: newTitle, + }); diff --git a/js/logreader-main.mjs.license b/js/logreader-main.mjs.license index fea791405..8f815387c 100644 --- a/js/logreader-main.mjs.license +++ b/js/logreader-main.mjs.license @@ -313,7 +313,7 @@ This file is generated from multiple sources. Included packages: - version: 4.0.3 - license: MIT - vite - - version: 7.3.6 + - version: 7.3.7 - license: MIT - vite-plugin-node-polyfills - version: 0.28.0 diff --git a/js/logreader-main.mjs.map.license b/js/logreader-main.mjs.map.license index fea791405..8f815387c 100644 --- a/js/logreader-main.mjs.map.license +++ b/js/logreader-main.mjs.map.license @@ -313,7 +313,7 @@ This file is generated from multiple sources. Included packages: - version: 4.0.3 - license: MIT - vite - - version: 7.3.6 + - version: 7.3.7 - license: MIT - vite-plugin-node-polyfills - version: 0.28.0 diff --git a/package-lock.json b/package-lock.json index 7c80b1a91..d711afb3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,7 @@ "browserslist": "^4.28.9", "happy-dom": "^20.9.0", "typescript": "^6.0.3", - "vite": "^7.3.1", + "vite": "^7.3.7", "vitest": "^4.1.11" }, "engines": { @@ -10645,9 +10645,9 @@ } }, "node_modules/vite": { - "version": "7.3.6", - "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.6.tgz", - "integrity": "sha512-4XP60spRGjSZFf1qYH+dJIkK2znL3zQfl9KkOV9MkkRR/3Dls0dxaBsQPTloEc5BLXWPL9vsOxopxyKoMmDueg==", + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.7.tgz", + "integrity": "sha512-AHEzTORMbi7/7aXp7w7KZ5+DCUdSeLsJz0grY8xHpc9DHdYb0vQu6DqJfm2tOw3gDExNgPgnJTXxM6syYFHaCA==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 6ba777e84..a91d0a907 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "browserslist": "^4.28.9", "happy-dom": "^20.9.0", "typescript": "^6.0.3", - "vite": "^7.3.1", + "vite": "^7.3.7", "vitest": "^4.1.11" }, "engines": {