1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-04-20 02:08:07 +00:00
This commit is contained in:
Michel Roegl-Brunner 2025-03-24 11:57:47 +01:00 committed by GitHub
parent 888b4c34bd
commit c9b5579869
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,117 +48,121 @@ jobs:
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with:
script: | script: |
const fs = require('fs').promises; async function main() {
const path = require('path'); const fs = require('fs').promises;
const path = require('path');
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 changelogConfig = JSON.parse(fileContent); const changelogConfig = JSON.parse(fileContent);
const categorizedPRs = changelogConfig.map(obj => ({ const categorizedPRs = changelogConfig.map(obj => ({
...obj, ...obj,
notes: [], notes: [],
subCategories: obj.subCategories ?? ( subCategories: obj.subCategories ?? (
obj.labels.includes("update script") ? [ obj.labels.includes("update script") ? [
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] }, { title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
{ title: "✨ New Features", labels: ["feature"], notes: [] }, { title: "✨ New Features", labels: ["feature"], notes: [] },
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] }, { title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] },
{ title: "🔧 Refactor", labels: ["refactor"], notes: [] }, { title: "🔧 Refactor", labels: ["refactor"], notes: [] },
] : ] :
obj.labels.includes("maintenance") ? [ obj.labels.includes("maintenance") ? [
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] }, { title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
{ title: "✨ New Features", labels: ["feature"], notes: [] }, { title: "✨ New Features", labels: ["feature"], notes: [] },
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] }, { title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] },
{ title: "📡 API", labels: ["api"], notes: [] }, { title: "📡 API", labels: ["api"], notes: [] },
{ title: "Github", labels: ["github"], notes: [] }, { title: "Github", labels: ["github"], notes: [] },
{ title: "📝 Documentation", labels: ["documentation"], notes: [] }, { title: "📝 Documentation", labels: ["documentation"], notes: [] },
{ title: "🔧 Refactor", labels: ["refactor"], notes: [] } { title: "🔧 Refactor", labels: ["refactor"], notes: [] }
] : ] :
obj.labels.includes("website") ? [ obj.labels.includes("website") ? [
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] }, { title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
{ title: "✨ New Features", labels: ["feature"], notes: [] }, { title: "✨ New Features", labels: ["feature"], notes: [] },
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] }, { title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] },
{ title: "Script Information", labels: ["json"], notes: [] } { title: "Script Information", labels: ["json"], notes: [] }
] : [] ] : []
) )
})); }));
const latestDateInChangelog = new Date(process.env.LATEST_DATE); const latestDateInChangelog = new Date(process.env.LATEST_DATE);
latestDateInChangelog.setUTCHours(23, 59, 59, 999); latestDateInChangelog.setUTCHours(23, 59, 59, 999);
const { data: pulls } = await github.rest.pulls.list({ const { data: pulls } = await github.rest.pulls.list({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
base: "main", base: "main",
state: "closed", state: "closed",
sort: "updated", sort: "updated",
direction: "desc", direction: "desc",
per_page: 100, per_page: 100,
}); });
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 => !pr.labels.some(label =>
["invalid", "wontdo", process.env.AUTOMATED_PR_LABEL].includes(label.name.toLowerCase()) ["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());
if (pr.user.login === "push-app-to-main") { if (pr.user.login === "push-app-to-main") {
const scriptName = pr.title; const scriptName = pr.title;
if (scriptName) { if (scriptName) {
try { try {
const { data: relatedIssues } = await github.rest.issues.listForRepo({ const { data: relatedIssues } = await github.rest.issues.listForRepo({
owner: context.repo.owner, owner: context.repo.owner,
repo: "ProxmoxVED", repo: "ProxmoxVED",
state: "all", state: "all",
label: "Started Migration To ProxmoxVE", label: "Started Migration To ProxmoxVE",
per_page: 5 per_page: 5
}); });
const matchingIssue = relatedIssues.find(issue => const matchingIssue = relatedIssues.find(issue =>
issue.title.toLowerCase().includes(scriptName.toLowerCase()) issue.title.toLowerCase().includes(scriptName.toLowerCase())
); );
if (matchingIssue) { if (matchingIssue) {
const issueAuthor = matchingIssue.user.login; const issueAuthor = matchingIssue.user.login;
const issueAuthorUrl = `https://github.com/${issueAuthor}`; const issueAuthorUrl = `https://github.com/${issueAuthor}`;
const prNote = `- ${pr.title} [@${issueAuthor}](${issueAuthorUrl}) ([#${pr.number}](${pr.html_url}))`; const prNote = `- ${pr.title} [@${issueAuthor}](${issueAuthorUrl}) ([#${pr.number}](${pr.html_url}))`;
} else { } else {
const prNote = `- ${pr.title} ([#${pr.number}](${pr.html_url}))`; const prNote = `- ${pr.title} ([#${pr.number}](${pr.html_url}))`;
}
} catch (error) {
console.error(`Error fetching related issues: ${error}`);
const prNote = `- ${pr.title} ([#${pr.number}](${pr.html_url}))`;
} }
} catch (error) { } else {
console.error(`Error fetching related issues: ${error}`); const prNote = `- ${pr.title} ([#${pr.number}](${pr.html_url}))`;
const prNote = `- ${pr.title} ([#${pr.number}](${pr.html_url}))`;
}
} else {
const prNote = `- ${pr.title} ([#${pr.number}](${pr.html_url}))`;
}else{ }else{
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 updateScriptsCategory = categorizedPRs.find(category => const updateScriptsCategory = categorizedPRs.find(category =>
category.labels.some(label => prLabels.includes(label)) category.labels.some(label => prLabels.includes(label))
);
if (updateScriptsCategory) {
const subCategory = updateScriptsCategory.subCategories.find(sub =>
sub.labels.some(label => prLabels.includes(label))
); );
if (subCategory) { if (updateScriptsCategory) {
subCategory.notes.push(prNote);
} else { const subCategory = updateScriptsCategory.subCategories.find(sub =>
updateScriptsCategory.notes.push(prNote); sub.labels.some(label => prLabels.includes(label))
);
if (subCategory) {
subCategory.notes.push(prNote);
} else {
updateScriptsCategory.notes.push(prNote);
}
} }
} });
console.log(JSON.stringify(categorizedPRs, null, 2));
return categorizedPRs;
}
main().catch(error => {
console.error("Error in script:", error);
}); });
console.log(JSON.stringify(categorizedPRs, null, 2));
return categorizedPRs;
- name: Update CHANGELOG.md - name: Update CHANGELOG.md
uses: actions/github-script@v7 uses: actions/github-script@v7
with: with: