Skip to content

Commit 4fd8e26

Browse files
authored
Update changelog-pr.yml
1 parent 37b7894 commit 4fd8e26

File tree

1 file changed

+45
-59
lines changed

1 file changed

+45
-59
lines changed

.github/workflows/changelog-pr.yml

Lines changed: 45 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -97,71 +97,60 @@ jobs:
9797
per_page: 100,
9898
});
9999
100-
pulls.filter(pr =>
100+
const filteredPRs = pulls.filter(pr =>
101101
pr.merged_at &&
102102
new Date(pr.merged_at) > latestDateInChangelog &&
103103
!pr.labels.some(label =>
104104
["invalid", "wontdo", process.env.AUTOMATED_PR_LABEL].includes(label.name.toLowerCase())
105-
)
106-
).forEach(pr => {
107-
108-
const prLabels = pr.labels.map(label => label.name.toLowerCase());
109-
if (pr.user.login === "push-app-to-main") {
110-
const scriptName = pr.title;
111-
if (scriptName) {
112-
try {
113-
const { data: relatedIssues } = await github.rest.issues.listForRepo({
114-
owner: context.repo.owner,
115-
repo: "ProxmoxVED",
116-
state: "all",
117-
label: "Started Migration To ProxmoxVE",
118-
per_page: 5
119-
});
120-
const matchingIssue = relatedIssues.find(issue =>
121-
issue.title.toLowerCase().includes(scriptName.toLowerCase())
122-
);
123-
if (matchingIssue) {
124-
const issueAuthor = matchingIssue.user.login;
125-
const issueAuthorUrl = `https://github.com/${issueAuthor}`;
126-
const prNote = `- ${pr.title} [@${issueAuthor}](${issueAuthorUrl}) ([#${pr.number}](${pr.html_url}))`;
127-
} else {
128-
const prNote = `- ${pr.title} ([#${pr.number}](${pr.html_url}))`;
129-
}
130-
} catch (error) {
131-
console.error(`Error fetching related issues: ${error}`);
132-
const prNote = `- ${pr.title} ([#${pr.number}](${pr.html_url}))`;
105+
)
106+
);
107+
108+
for (const pr of filteredPRs) { // ✅ for...of unterstützt await
109+
const prLabels = pr.labels.map(label => label.name.toLowerCase());
110+
111+
let prNote = `- ${pr.title} [@${pr.user.login}](https://github.com/${pr.user.login}) ([#${pr.number}](${pr.html_url}))`;
112+
113+
if (pr.user.login === "push-app-to-main") {
114+
const scriptName = pr.title;
115+
if (scriptName) {
116+
try {
117+
const { data: relatedIssues } = await github.rest.issues.listForRepo({
118+
owner: context.repo.owner,
119+
repo: "ProxmoxVED",
120+
state: "all",
121+
labels: ["Started Migration To ProxmoxVE"], // "label" -> "labels"
122+
per_page: 5
123+
});
124+
const matchingIssue = relatedIssues.find(issue =>
125+
issue.title.toLowerCase().includes(scriptName.toLowerCase())
126+
);
127+
if (matchingIssue) {
128+
const issueAuthor = matchingIssue.user.login;
129+
const issueAuthorUrl = `https://github.com/${issueAuthor}`;
130+
prNote = `- ${pr.title} [@${issueAuthor}](${issueAuthorUrl}) ([#${pr.number}](${pr.html_url}))`;
133131
}
134-
} else {
135-
const prNote = `- ${pr.title} ([#${pr.number}](${pr.html_url}))`;
136-
137-
}else{
138-
const prNote = `- ${pr.title} [@${pr.user.login}](https://github.com/${pr.user.login}) ([#${pr.number}](${pr.html_url}))`;
132+
} catch (error) {
133+
console.error(`Error fetching related issues: ${error}`);
134+
}
139135
}
140-
const updateScriptsCategory = categorizedPRs.find(category =>
141-
category.labels.some(label => prLabels.includes(label))
136+
}
137+
138+
const updateScriptsCategory = categorizedPRs.find(category =>
139+
category.labels.some(label => prLabels.includes(label))
140+
);
141+
142+
if (updateScriptsCategory) {
143+
const subCategory = updateScriptsCategory.subCategories.find(sub =>
144+
sub.labels.some(label => prLabels.includes(label))
142145
);
143-
144-
if (updateScriptsCategory) {
145-
146-
const subCategory = updateScriptsCategory.subCategories.find(sub =>
147-
sub.labels.some(label => prLabels.includes(label))
148-
);
149-
150-
if (subCategory) {
151-
subCategory.notes.push(prNote);
152-
} else {
153-
updateScriptsCategory.notes.push(prNote);
154-
}
146+
147+
if (subCategory) {
148+
subCategory.notes.push(prNote);
149+
} else {
150+
updateScriptsCategory.notes.push(prNote);
155151
}
156-
});
157-
158-
console.log(JSON.stringify(categorizedPRs, null, 2));
159-
160-
return categorizedPRs;
152+
}
161153
}
162-
main().catch(error => {
163-
console.error("Error in script:", error);
164-
});
165154
166155
- name: Update CHANGELOG.md
167156
uses: actions/github-script@v7
@@ -184,8 +173,6 @@ jobs:
184173
const hasMainNotes = notes.length > 0;
185174
const hasSubNotes = hasSubcategories && subCategories.some(sub => sub.notes && sub.notes.length > 0);
186175
187-
188-
189176
if (hasMainNotes || hasSubNotes) {
190177
newReleaseNotes += `### ${title}\n\n`;
191178
}
@@ -202,7 +189,6 @@ jobs:
202189
}
203190
}
204191
}
205-
206192
const changelogContent = await fs.readFile(changelogPath, 'utf-8');
207193
const changelogIncludesTodaysReleaseNotes = changelogContent.includes(`\n## ${today}`);
208194

0 commit comments

Comments
 (0)