@@ -34,14 +34,13 @@ jobs:
3434 run : npm install axios
3535
3636 - name : Validate Download Links
37- env :
38- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3937 run : |
40- node <<' EOF'
38+ node <<EOF
4139 const axios = require('axios');
4240 const fs = require('fs');
4341
44- // Read and parse the badges.json file
42+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
43+
4544 const badges = JSON.parse(fs.readFileSync('./badges.json', 'utf-8'));
4645 const plugins = badges.plugins;
4746
@@ -57,26 +56,25 @@ jobs:
5756 const repoName = repoUrl.replace('https://github.com/', '');
5857 const apiUrl = `https://api.github.com/repos/${repoName}/releases/latest`;
5958
59+ // Add a delay to throttle requests
60+ await sleep(2000); // 2 seconds delay between requests
61+
6062 // Fetch the latest release information
6163 const response = await axios.get(apiUrl, {
6264 headers: {
6365 'User-Agent': 'GitHub Actions',
64- Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
6566 Accept: 'application/vnd.github.v3+json',
6667 },
6768 });
6869
6970 const latestDownloadUrl = response.data.assets[0]?.browser_download_url || null;
7071
7172 if (!latestDownloadUrl) {
72- // No downloadable asset in the latest release
7373 console.warn(`⚠️ ${plugin.name}: No downloadable asset found in the latest release.`);
7474 console.log(`::warning file=badges.json,line=1::${plugin.name} has no downloadable asset in its latest release.`);
7575 } else if (releaseUrl === latestDownloadUrl) {
76- // Download link matches the latest release
7776 console.log(`✅ ${plugin.name}: Download link is up-to-date.`);
7877 } else {
79- // Download link is outdated
8078 console.error(`❌ ${plugin.name}: Download link is outdated.`);
8179 console.error(` Expected: ${latestDownloadUrl}`);
8280 console.error(` Found: ${releaseUrl}`);
@@ -107,3 +105,5 @@ jobs:
107105 validateLinks().catch(err => {
108106 console.error("Unhandled error:", err.message);
109107 process.exit(1);
108+ });
109+ EOF
0 commit comments