mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-02-23 13:11:29 +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
|
- name: Get latest dates in changelog
|
||||||
run: |
|
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}')
|
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')
|
LATEST_DATE=$(echo "$DATES" | sed -n '1p')
|
||||||
SECOND_LATEST_DATE=$(echo "$DATES" | sed -n '2p')
|
SECOND_LATEST_DATE=$(echo "$DATES" | sed -n '2p')
|
||||||
TODAY=$(date -u +%Y-%m-%d)
|
TODAY=$(date -u +%Y-%m-%d)
|
||||||
@ -42,7 +44,7 @@ jobs:
|
|||||||
echo "LATEST_DATE=$LATEST_DATE" >> $GITHUB_ENV
|
echo "LATEST_DATE=$LATEST_DATE" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Get categorized pull requests (including PR template selections)
|
- name: Get categorized pull requests
|
||||||
id: get-categorized-prs
|
id: get-categorized-prs
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
@ -52,22 +54,7 @@ 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');
|
||||||
let changelogConfig = JSON.parse(fileContent);
|
const 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 categorizedPRs = changelogConfig.map(obj => ({ ...obj, notes: [] }));
|
const categorizedPRs = changelogConfig.map(obj => ({ ...obj, notes: [] }));
|
||||||
|
|
||||||
const latestDateInChangelog = new Date(process.env.LATEST_DATE);
|
const latestDateInChangelog = new Date(process.env.LATEST_DATE);
|
||||||
@ -83,65 +70,23 @@ jobs:
|
|||||||
per_page: 100,
|
per_page: 100,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!pulls || pulls.length === 0) {
|
|
||||||
console.log("⚠️ Keine gemergten PRs gefunden. Setze leeres Changelog.");
|
|
||||||
core.setOutput("result", "[]");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pulls.filter(pr =>
|
pulls.filter(pr =>
|
||||||
pr.merged_at &&
|
pr.merged_at &&
|
||||||
new Date(pr.merged_at) > latestDateInChangelog &&
|
new Date(pr.merged_at) > latestDateInChangelog &&
|
||||||
!pr.labels.some(label => ["invalid", "wontdo", process.env.AUTOMATED_PR_LABEL].includes(label.name.toLowerCase()))
|
!pr.labels.some(label => ["invalid", "wontdo", process.env.AUTOMATED_PR_LABEL].includes(label.name.toLowerCase()))
|
||||||
).forEach(pr => {
|
).forEach(pr => {
|
||||||
const prLabels = pr.labels.map(label => label.name.toLowerCase());
|
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 prNote = `- ${pr.title} [@${pr.user.login}](https://github.com/${pr.user.login}) ([#${pr.number}](${pr.html_url}))`;
|
||||||
|
|
||||||
const templateLabelMappings = {
|
for (const { labels, notes } of categorizedPRs) {
|
||||||
"🐞 bug fix": "bugfix",
|
if (labels.length === 0 || labels.some(label => prLabels.includes(label))) {
|
||||||
"✨ 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))) {
|
|
||||||
notes.push(prNote);
|
notes.push(prNote);
|
||||||
categorized = true;
|
|
||||||
break;
|
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
|
- name: Update CHANGELOG.md
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
@ -153,11 +98,7 @@ jobs:
|
|||||||
const today = process.env.TODAY;
|
const today = process.env.TODAY;
|
||||||
const latestDateInChangelog = process.env.LATEST_DATE;
|
const latestDateInChangelog = process.env.LATEST_DATE;
|
||||||
const changelogPath = path.resolve('CHANGELOG.md');
|
const changelogPath = path.resolve('CHANGELOG.md');
|
||||||
const result = `${{ steps.get-categorized-prs.outputs.result }}`.trim();
|
const categorizedPRs = ${{ steps.get-categorized-prs.outputs.result }};
|
||||||
|
|
||||||
console.log("🔹 Ergebnis aus get-categorized-prs:", result);
|
|
||||||
|
|
||||||
const categorizedPRs = result && result !== "undefined" ? JSON.parse(result) : [];
|
|
||||||
|
|
||||||
let newReleaseNotes = `## ${today}\n\n### Changes\n\n`;
|
let newReleaseNotes = `## ${today}\n\n### Changes\n\n`;
|
||||||
for (const { title, notes } of categorizedPRs) {
|
for (const { title, notes } of categorizedPRs) {
|
||||||
@ -169,6 +110,7 @@ jobs:
|
|||||||
const changelogContent = await fs.readFile(changelogPath, 'utf-8');
|
const changelogContent = await fs.readFile(changelogPath, 'utf-8');
|
||||||
const changelogIncludesTodaysReleaseNotes = changelogContent.includes(`\n## ${today}`);
|
const changelogIncludesTodaysReleaseNotes = changelogContent.includes(`\n## ${today}`);
|
||||||
|
|
||||||
|
// Ersetze oder füge Release Notes ein
|
||||||
const regex = changelogIncludesTodaysReleaseNotes
|
const regex = changelogIncludesTodaysReleaseNotes
|
||||||
? new RegExp(`## ${today}.*(?=## ${latestDateInChangelog})`, "gs")
|
? new RegExp(`## ${today}.*(?=## ${latestDateInChangelog})`, "gs")
|
||||||
: new RegExp(`(?=## ${latestDateInChangelog})`, "gs");
|
: new RegExp(`(?=## ${latestDateInChangelog})`, "gs");
|
||||||
|
Loading…
Reference in New Issue
Block a user