mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-02-22 20:51:10 +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
|
- name: Install minimatch
|
||||||
run: npm 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
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
@ -30,8 +30,12 @@ jobs:
|
|||||||
const configPath = path.resolve(process.env.CONFIG_PATH);
|
const configPath = path.resolve(process.env.CONFIG_PATH);
|
||||||
const fileContent = await fs.readFile(configPath, 'utf-8');
|
const fileContent = await fs.readFile(configPath, 'utf-8');
|
||||||
const autolabelerConfig = JSON.parse(fileContent);
|
const autolabelerConfig = JSON.parse(fileContent);
|
||||||
|
|
||||||
const prNumber = context.payload.pull_request.number;
|
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({
|
const prListFilesResponse = await github.rest.pulls.listFiles({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
@ -39,8 +43,6 @@ 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) => {
|
||||||
@ -57,34 +59,17 @@ jobs:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (labelsToAdd.size > 0) {
|
const templateLabelMappings = {
|
||||||
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",
|
"🐞 bug fix": "bug fix",
|
||||||
"✨ new feature": "new feature",
|
"✨ new feature": "new feature",
|
||||||
"💥 breaking change": "breaking change",
|
"💥 breaking change": "breaking change",
|
||||||
"🆕 new script": "new script"
|
"🆕 new script": "new script"
|
||||||
};
|
};
|
||||||
|
|
||||||
let labelsToAdd = new Set();
|
for (const [checkbox, label] of Object.entries(templateLabelMappings)) {
|
||||||
|
|
||||||
for (const [checkbox, label] of Object.entries(labelMappings)) {
|
|
||||||
const regex = new RegExp(`- \\[(.*?)\\] ${checkbox}`, "i");
|
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);
|
labelsToAdd.add(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user