mirror of
https://github.com/nextcloud/server.git
synced 2026-03-28 21:33:40 -04:00
45 lines
1.5 KiB
YAML
45 lines
1.5 KiB
YAML
# 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}`);
|
|
}
|
|
}
|