Skip to content

Commit 61ae831

Browse files
authored
Merge pull request #2111 from nextcloud/chore/noid/workflows
chore: add update-stable-titles worfklow, exclude IDE dirs with .gitignore
2 parents c25d930 + 9c57079 commit 61ae831

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: MIT
3+
name: Update PRs titles on stable branches
4+
5+
on:
6+
pull_request:
7+
types: [opened, edited]
8+
branches:
9+
- "stable*"
10+
11+
concurrency:
12+
group: stable-pr-title-${{ github.event.pull_request.number }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
update-pr-title:
17+
runs-on: ubuntu-latest-low
18+
permissions:
19+
pull-requests: write
20+
contents: read
21+
22+
steps:
23+
- name: Wait for potential title edits
24+
run: sleep 15
25+
26+
- name: Get PR details and update title
27+
# Renovate already have target branch in the title
28+
if: github.event.pull_request.user.login != 'renovate[bot]'
29+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
30+
with:
31+
github-token: ${{ secrets.GITHUB_TOKEN }}
32+
script: |
33+
const { data: pr } = await github.rest.pulls.get({
34+
owner: context.repo.owner,
35+
repo: context.repo.repo,
36+
pull_number: context.issue.number,
37+
});
38+
39+
const baseBranch = pr.base.ref;
40+
const currentTitle = pr.title;
41+
42+
// Check if this is a stable branch
43+
// Should not happen as we only trigger on stable* branches 🤷‍♀️
44+
if (!baseBranch.startsWith('stable')) {
45+
console.log(`Not a stable branch: ${baseBranch}`);
46+
return;
47+
}
48+
49+
const prefix = `[${baseBranch}]`;
50+
51+
// Check if title already has the correct prefix and no other stable tags
52+
const correctTagRegex = new RegExp(`^\\[${baseBranch}\\]\\s*`);
53+
const hasOtherStableTags = /\[stable[\d.]*\]/.test(currentTitle.replace(correctTagRegex, ''));
54+
55+
if (correctTagRegex.test(currentTitle) && !hasOtherStableTags) {
56+
console.log(`Title already has correct prefix only: ${currentTitle}`);
57+
return;
58+
}
59+
60+
// Remove all stable tags and add the correct one
61+
const cleanTitle = currentTitle.replace(/\[stable[\d.]*\]\s*/g, '').trim();
62+
const newTitle = `${prefix} ${cleanTitle}`;
63+
64+
console.log(`Updating title from: "${currentTitle}" to: "${newTitle}"`);
65+
66+
await github.rest.pulls.update({
67+
owner: context.repo.owner,
68+
repo: context.repo.repo,
69+
pull_number: context.issue.number,
70+
title: newTitle,
71+
});

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,13 @@ vendor/
1515

1616
build/
1717
*.cache
18+
19+
# VScode settings
20+
.vscode/
21+
*.code-workspace
22+
23+
# JetBrains IDEs settings
24+
.idea/
25+
26+
# JetBrains Fleet settings
27+
.fleet/

0 commit comments

Comments
 (0)