fix: not fetch existing changelog (#2330)

fix: not fetch existing changelog
This commit is contained in:
Henry 2024-03-12 22:14:16 +09:00 committed by GitHub
commit 0747c15581
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,6 @@
const fs = require('fs');
const path = require('path');
const fetch = require('node-fetch');
async function fetchData(siteConfig) {
const owner = siteConfig.organizationName;
@ -70,6 +71,14 @@ async function fetchData(siteConfig) {
// Process the GitHub releases data here
for (const release of releases) {
const version = release.tag_name;
// Check if the changelog file already exists for the current version
const existingChangelogPath = path.join(outputDirectory, `changelog-${version}.mdx`);
if (fs.existsSync(existingChangelogPath)) {
console.log(`Changelog for version ${version} already exists. Skipping...`);
continue;
}
const releaseUrl = release.html_url;
const issueNumberMatch = release.body.match(/#(\d+)/);
const issueNumber = issueNumberMatch ? parseInt(issueNumberMatch[1], 10) : null;