-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
45 lines (41 loc) · 1.54 KB
/
bug-report-labeler.yml
File metadata and controls
45 lines (41 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
name: Auto-label bug reports
on:
issues:
types: [opened]
jobs:
add-version-label:
if: contains(github.event.issue.title, '[Bug]')
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Extract version number and apply label
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const body = context.payload.issue.body || '';
const normalizedBody = body.replace(/\r\n?/g, '\n');
let label = '';
// Extract Nextcloud Server version number from a block like:
// ### Nextcloud Server version
// 32
const versionMatch = normalizedBody.match(/### Nextcloud Server version\s*\n+([0-9]{1,3})\b/);
let nextcloudVersion = null;
if (versionMatch) {
nextcloudVersion = parseInt(versionMatch[1], 10);
label = nextcloudVersion + '-feedback';
}
if (label) {
try {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [label]
});
} catch (error) {
core.setFailed(`Failed to add label "${label}": ${error.message || error}`);
}
}