mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-02-22 12:41:14 +01:00
Update autolabeler.yml
This commit is contained in:
parent
49bcd30e77
commit
8cb3007d66
35
.github/workflows/autolabeler.yml
vendored
35
.github/workflows/autolabeler.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
||||
- name: Install minimatch
|
||||
run: npm install minimatch
|
||||
|
||||
- name: Label PR based on file changes
|
||||
- name: Label PR based on file changes and PR template
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
@ -30,8 +30,12 @@ jobs:
|
||||
const configPath = path.resolve(process.env.CONFIG_PATH);
|
||||
const fileContent = await fs.readFile(configPath, 'utf-8');
|
||||
const autolabelerConfig = JSON.parse(fileContent);
|
||||
|
||||
|
||||
const prNumber = context.payload.pull_request.number;
|
||||
const prBody = context.payload.pull_request.body.toLowerCase();
|
||||
|
||||
let labelsToAdd = new Set();
|
||||
|
||||
const prListFilesResponse = await github.rest.pulls.listFiles({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
@ -39,8 +43,6 @@ jobs:
|
||||
});
|
||||
const prFiles = prListFilesResponse.data;
|
||||
|
||||
let labelsToAdd = new Set();
|
||||
|
||||
for (const [label, rules] of Object.entries(autolabelerConfig)) {
|
||||
const shouldAddLabel = prFiles.some((prFile) => {
|
||||
return rules.some((rule) => {
|
||||
@ -57,34 +59,17 @@ jobs:
|
||||
}
|
||||
}
|
||||
|
||||
if (labelsToAdd.size > 0) {
|
||||
console.log(`Adding labels ${Array.from(labelsToAdd).join(", ")} to PR ${prNumber}`);
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: prNumber,
|
||||
labels: Array.from(labelsToAdd),
|
||||
});
|
||||
}
|
||||
|
||||
- name: Label PR based on PR template selections
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const prBody = context.payload.pull_request.body.toLowerCase();
|
||||
const prNumber = context.payload.pull_request.number;
|
||||
const labelMappings = {
|
||||
const templateLabelMappings = {
|
||||
"🐞 bug fix": "bug fix",
|
||||
"✨ new feature": "new feature",
|
||||
"💥 breaking change": "breaking change",
|
||||
"🆕 new script": "new script"
|
||||
};
|
||||
|
||||
let labelsToAdd = new Set();
|
||||
|
||||
for (const [checkbox, label] of Object.entries(labelMappings)) {
|
||||
for (const [checkbox, label] of Object.entries(templateLabelMappings)) {
|
||||
const regex = new RegExp(`- \\[(.*?)\\] ${checkbox}`, "i");
|
||||
if (regex.test(prBody)) {
|
||||
const match = prBody.match(regex);
|
||||
if (match && match[1].trim() !== "") { // Checkbox ist gesetzt
|
||||
labelsToAdd.add(label);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user