mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-03-10 15:40:01 +00:00
[gh] better handling of labels (#2517)
* Update autolabeler.yml * Update changelog-pr-config.json
This commit is contained in:
parent
1fe8bc05b3
commit
20414d9659
36
.github/changelog-pr-config.json
vendored
36
.github/changelog-pr-config.json
vendored
@ -1,34 +1,38 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"title": "💥 Breaking Changes",
|
"title": "💥 Breaking Changes",
|
||||||
"labels": ["breaking change"]
|
"labels": ["breaking change"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "✨ New Scripts",
|
"title": "✨ New Scripts",
|
||||||
"labels": ["new script"]
|
"labels": ["new script"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "🚀 Updated Scripts",
|
"title": "🚀 Updated Scripts",
|
||||||
"labels": ["update script"]
|
"labels": ["update script"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "🌐 Website",
|
"title": "🆕 Features",
|
||||||
"labels": ["website"]
|
"labels": ["new feature"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "🐞 Bug Fixes",
|
"title": "🌐 Website",
|
||||||
"labels": ["bug fix"]
|
"labels": ["website"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "🧰 Maintenance",
|
"title": "🐞 Bug Fixes",
|
||||||
"labels": ["maintenance"]
|
"labels": ["bug fix"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "📡 API",
|
"title": "🧰 Maintenance",
|
||||||
"labels": ["api"]
|
"labels": ["maintenance"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "❔ Unlabelled",
|
"title": "📡 API",
|
||||||
"labels": []
|
"labels": ["api"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "❔ Unlabelled",
|
||||||
|
"labels": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
54
.github/workflows/autolabeler.yml
vendored
54
.github/workflows/autolabeler.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
- name: Install minimatch
|
- name: Install minimatch
|
||||||
run: npm install minimatch
|
run: npm install minimatch
|
||||||
|
|
||||||
- name: Label PR based on config rules
|
- name: Label PR based on file changes
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
@ -39,6 +39,8 @@ jobs:
|
|||||||
});
|
});
|
||||||
const prFiles = prListFilesResponse.data;
|
const prFiles = prListFilesResponse.data;
|
||||||
|
|
||||||
|
let labelsToAdd = new Set();
|
||||||
|
|
||||||
for (const [label, rules] of Object.entries(autolabelerConfig)) {
|
for (const [label, rules] of Object.entries(autolabelerConfig)) {
|
||||||
const shouldAddLabel = prFiles.some((prFile) => {
|
const shouldAddLabel = prFiles.some((prFile) => {
|
||||||
return rules.some((rule) => {
|
return rules.some((rule) => {
|
||||||
@ -51,12 +53,48 @@ jobs:
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (shouldAddLabel) {
|
if (shouldAddLabel) {
|
||||||
console.log(`Adding label ${label} to PR ${prNumber}`);
|
labelsToAdd.add(label);
|
||||||
await github.rest.issues.addLabels({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
|
||||||
issue_number: prNumber,
|
|
||||||
labels: [label],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 = {
|
||||||
|
"🐞 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)) {
|
||||||
|
const regex = new RegExp(`- \\[(.*?)\\] ${checkbox}`, "i");
|
||||||
|
if (regex.test(prBody)) {
|
||||||
|
labelsToAdd.add(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user