mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-02-22 12:41:14 +01:00
Update changelog-pr.yml
This commit is contained in:
parent
d0cd58e923
commit
109c48694e
76
.github/workflows/changelog-pr.yml
vendored
76
.github/workflows/changelog-pr.yml
vendored
@ -30,7 +30,9 @@ jobs:
|
||||
|
||||
- name: Get latest dates in changelog
|
||||
run: |
|
||||
# Extrahiere die neuesten zwei Daten aus dem Changelog
|
||||
DATES=$(grep -E '^## [0-9]{4}-[0-9]{2}-[0-9]{2}' CHANGELOG.md | head -n 2 | awk '{print $2}')
|
||||
|
||||
LATEST_DATE=$(echo "$DATES" | sed -n '1p')
|
||||
SECOND_LATEST_DATE=$(echo "$DATES" | sed -n '2p')
|
||||
TODAY=$(date -u +%Y-%m-%d)
|
||||
@ -42,7 +44,7 @@ jobs:
|
||||
echo "LATEST_DATE=$LATEST_DATE" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Get categorized pull requests (including PR template selections)
|
||||
- name: Get categorized pull requests
|
||||
id: get-categorized-prs
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
@ -52,22 +54,7 @@ jobs:
|
||||
|
||||
const configPath = path.resolve(process.env.CONFIG_PATH);
|
||||
const fileContent = await fs.readFile(configPath, 'utf-8');
|
||||
let changelogConfig = JSON.parse(fileContent);
|
||||
|
||||
const order = [
|
||||
"💥 Breaking Changes",
|
||||
"🆕 New Scripts",
|
||||
"🚀 Updated Scripts",
|
||||
"🐞 Bug Fixes (Updated Scripts)",
|
||||
"✨ Feature Updates (Updated Scripts)",
|
||||
"✨ New Features",
|
||||
"🌐 Website",
|
||||
"📡 API",
|
||||
"🧰 Maintenance",
|
||||
"❔ Unlabelled"
|
||||
];
|
||||
changelogConfig = changelogConfig.sort((a, b) => order.indexOf(a.title) - order.indexOf(b.title));
|
||||
|
||||
const changelogConfig = JSON.parse(fileContent);
|
||||
const categorizedPRs = changelogConfig.map(obj => ({ ...obj, notes: [] }));
|
||||
|
||||
const latestDateInChangelog = new Date(process.env.LATEST_DATE);
|
||||
@ -83,65 +70,23 @@ jobs:
|
||||
per_page: 100,
|
||||
});
|
||||
|
||||
if (!pulls || pulls.length === 0) {
|
||||
console.log("⚠️ Keine gemergten PRs gefunden. Setze leeres Changelog.");
|
||||
core.setOutput("result", "[]");
|
||||
return;
|
||||
}
|
||||
|
||||
pulls.filter(pr =>
|
||||
pr.merged_at &&
|
||||
new Date(pr.merged_at) > latestDateInChangelog &&
|
||||
!pr.labels.some(label => ["invalid", "wontdo", process.env.AUTOMATED_PR_LABEL].includes(label.name.toLowerCase()))
|
||||
).forEach(pr => {
|
||||
const prLabels = pr.labels.map(label => label.name.toLowerCase());
|
||||
const prBody = pr.body ? pr.body.toLowerCase() : "";
|
||||
const prNote = `- ${pr.title} [@${pr.user.login}](https://github.com/${pr.user.login}) ([#${pr.number}](${pr.html_url}))`;
|
||||
|
||||
const templateLabelMappings = {
|
||||
"🐞 bug fix": "bugfix",
|
||||
"✨ new feature": "feature",
|
||||
"💥 breaking change": "breaking change",
|
||||
"🆕 new script": "new script"
|
||||
};
|
||||
|
||||
let addedByTemplate = false;
|
||||
for (const [checkbox, label] of Object.entries(templateLabelMappings)) {
|
||||
const regex = new RegExp(`- \\[(.*?)\\] ${checkbox}`, "i");
|
||||
const match = prBody.match(regex);
|
||||
if (match && match[1].trim() !== "") {
|
||||
prLabels.push(label);
|
||||
addedByTemplate = true;
|
||||
}
|
||||
}
|
||||
|
||||
let categorized = false;
|
||||
for (const { labels, notes, title } of categorizedPRs) {
|
||||
if (labels.includes("update script") && labels.includes("bugfix")) {
|
||||
if (title === "🐞 Bug Fixes (Updated Scripts)") {
|
||||
notes.push(prNote);
|
||||
categorized = true;
|
||||
break;
|
||||
}
|
||||
} else if (labels.includes("update script") && labels.includes("feature")) {
|
||||
if (title === "✨ Feature Updates (Updated Scripts)") {
|
||||
notes.push(prNote);
|
||||
categorized = true;
|
||||
break;
|
||||
}
|
||||
} else if (labels.length === 0 || labels.some(label => prLabels.includes(label))) {
|
||||
for (const { labels, notes } of categorizedPRs) {
|
||||
if (labels.length === 0 || labels.some(label => prLabels.includes(label))) {
|
||||
notes.push(prNote);
|
||||
categorized = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (addedByTemplate) {
|
||||
console.log(`PR #${pr.number} wurde durch PR-Template-Kategorie hinzugefügt.`);
|
||||
}
|
||||
});
|
||||
|
||||
core.setOutput("result", JSON.stringify(categorizedPRs.length ? categorizedPRs : []));
|
||||
return categorizedPRs;
|
||||
|
||||
- name: Update CHANGELOG.md
|
||||
uses: actions/github-script@v7
|
||||
@ -153,11 +98,7 @@ jobs:
|
||||
const today = process.env.TODAY;
|
||||
const latestDateInChangelog = process.env.LATEST_DATE;
|
||||
const changelogPath = path.resolve('CHANGELOG.md');
|
||||
const result = `${{ steps.get-categorized-prs.outputs.result }}`.trim();
|
||||
|
||||
console.log("🔹 Ergebnis aus get-categorized-prs:", result);
|
||||
|
||||
const categorizedPRs = result && result !== "undefined" ? JSON.parse(result) : [];
|
||||
const categorizedPRs = ${{ steps.get-categorized-prs.outputs.result }};
|
||||
|
||||
let newReleaseNotes = `## ${today}\n\n### Changes\n\n`;
|
||||
for (const { title, notes } of categorizedPRs) {
|
||||
@ -169,6 +110,7 @@ jobs:
|
||||
const changelogContent = await fs.readFile(changelogPath, 'utf-8');
|
||||
const changelogIncludesTodaysReleaseNotes = changelogContent.includes(`\n## ${today}`);
|
||||
|
||||
// Ersetze oder füge Release Notes ein
|
||||
const regex = changelogIncludesTodaysReleaseNotes
|
||||
? new RegExp(`## ${today}.*(?=## ${latestDateInChangelog})`, "gs")
|
||||
: new RegExp(`(?=## ${latestDateInChangelog})`, "gs");
|
||||
|
Loading…
Reference in New Issue
Block a user