Skip to content

Commit 987a52b

Browse files
authored
Merge pull request #58657 from nextcloud/enh/noid/auto-label-reports
feat: add workflow that auto-labels bug reports based on entered content
2 parents e7c4dbf + e0bf073 commit 987a52b

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

.github/ISSUE_TEMPLATE/BUG_REPORT.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ body:
7373
options:
7474
- "32"
7575
- "33"
76-
- "master"
76+
- "34 (master)"
7777
validations:
7878
required: true
7979
- type: dropdown
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
2+
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
4+
name: Auto-label bug reports
5+
on:
6+
issues:
7+
types: [opened]
8+
9+
jobs:
10+
add-version-label:
11+
if: contains(github.event.issue.title, '[Bug]')
12+
runs-on: ubuntu-latest
13+
permissions:
14+
issues: write
15+
steps:
16+
- name: Extract version number and apply label
17+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
18+
with:
19+
script: |
20+
const body = context.payload.issue.body || '';
21+
const normalizedBody = body.replace(/\r\n?/g, '\n');
22+
let label = '';
23+
24+
// Extract Nextcloud Server version number from a block like:
25+
// ### Nextcloud Server version
26+
// 32
27+
const versionMatch = normalizedBody.match(/### Nextcloud Server version\s*\n+([0-9]{1,3})\b/);
28+
let nextcloudVersion = null;
29+
if (versionMatch) {
30+
nextcloudVersion = parseInt(versionMatch[1], 10);
31+
label = nextcloudVersion + '-feedback';
32+
}
33+
34+
if (label) {
35+
try {
36+
await github.rest.issues.addLabels({
37+
issue_number: context.issue.number,
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
labels: [label]
41+
});
42+
} catch (error) {
43+
core.setFailed(`Failed to add label "${label}": ${error.message || error}`);
44+
}
45+
}

0 commit comments

Comments
 (0)