Skip to content

Commit 194c9bb

Browse files
authored
Update check-plugin-links.yml
Test 4
1 parent fc1a49a commit 194c9bb

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

.github/workflows/check-plugin-links.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
const axios = require('axios');
4545
const fs = require('fs');
4646
47+
// Read and parse the badges.json file
4748
const badges = JSON.parse(fs.readFileSync('./badges.json', 'utf-8'));
4849
const plugins = badges.plugins;
4950
@@ -55,26 +56,35 @@ jobs:
5556
const releaseUrl = plugin.releaseUrl;
5657
5758
try {
59+
// Generate API URL for the repository's latest release
5860
const repoName = repoUrl.replace('https://github.com/', '');
5961
const apiUrl = `https://api.github.com/repos/${repoName}/releases/latest`;
62+
63+
// Fetch the latest release information
6064
const response = await axios.get(apiUrl, {
6165
headers: { 'User-Agent': 'GitHub Actions', Accept: 'application/vnd.github.v3+json' }
6266
});
67+
68+
// Extract the download URL of the latest release's asset
6369
const latestDownloadUrl = response.data.assets[0]?.browser_download_url || null;
6470
6571
if (!latestDownloadUrl) {
72+
// No downloadable asset in the latest release
6673
console.warn(`⚠️ ${plugin.name}: No downloadable asset found in the latest release.`);
6774
console.log(`::warning file=badges.json,line=1::${plugin.name} has no downloadable asset in its latest release.`);
6875
} else if (releaseUrl === latestDownloadUrl) {
76+
// Download link matches the latest release
6977
console.log(`✅ ${plugin.name}: Download link is up-to-date.`);
7078
} else {
79+
// Download link is outdated
7180
console.error(`❌ ${plugin.name}: Download link is outdated.`);
7281
console.error(` Expected: ${latestDownloadUrl}`);
7382
console.error(` Found: ${releaseUrl}`);
7483
console.log(`::error file=badges.json,line=1::${plugin.name} has an outdated download link.`);
7584
hasErrors = true;
7685
}
7786
} catch (error) {
87+
// Handle errors during API call
7888
console.error(`⚠️ Error checking ${plugin.name}: ${error.message}`);
7989
console.log(`::error file=badges.json,line=1::${plugin.name} encountered an error: ${error.message}`);
8090
hasErrors = true;
@@ -86,5 +96,8 @@ jobs:
8696
}
8797
}
8898
89-
validateLinks();
99+
validateLinks().catch(err => {
100+
console.error("Unhandled error:", err.message);
101+
process.exit(1);
102+
});
90103
EOF

0 commit comments

Comments
 (0)