Skip to content

Commit 25df288

Browse files
authored
Update check-plugin-links.yml
Test 8
1 parent 1dfc0a7 commit 25df288

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

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

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ jobs:
1818
run: |
1919
git fetch origin gh-pages:gh-pages || echo "gh-pages branch does not exist."
2020
git checkout gh-pages || echo "Failed to checkout gh-pages."
21-
if [ -f badges.json ]; then
22-
echo "badges.json successfully fetched from gh-pages."
23-
else
21+
if [ ! -f badges.json ]; then
2422
echo "No badges.json file found in gh-pages branch."
2523
exit 1
2624
fi
@@ -35,7 +33,8 @@ jobs:
3533

3634
- name: Validate Download Links
3735
run: |
38-
node <<EOF
36+
echo 'Starting validation script'
37+
echo "
3938
const axios = require('axios');
4039
const fs = require('fs');
4140
@@ -52,14 +51,11 @@ jobs:
5251
const releaseUrl = plugin.releaseUrl;
5352
5453
try {
55-
// Generate API URL for the repository's latest release
5654
const repoName = repoUrl.replace('https://github.com/', '');
5755
const apiUrl = `https://api.github.com/repos/${repoName}/releases/latest`;
5856
59-
// Add a delay to throttle requests
60-
await sleep(2000); // 2 seconds delay between requests
57+
await sleep(2000); // Throttle requests with 2 seconds delay
6158
62-
// Fetch the latest release information
6359
const response = await axios.get(apiUrl, {
6460
headers: {
6561
'User-Agent': 'GitHub Actions',
@@ -70,28 +66,28 @@ jobs:
7066
const latestDownloadUrl = response.data.assets[0]?.browser_download_url || null;
7167
7268
if (!latestDownloadUrl) {
73-
console.warn(`⚠️ ${plugin.name}: No downloadable asset found in the latest release.`);
74-
console.log(`::warning file=badges.json,line=1::${plugin.name} has no downloadable asset in its latest release.`);
69+
console.warn(\`⚠️ ${plugin.name}: No downloadable asset found in the latest release.\`);
70+
console.log(\`::warning file=badges.json,line=1::${plugin.name} has no downloadable asset in its latest release.\`);
7571
} else if (releaseUrl === latestDownloadUrl) {
76-
console.log(`✅ ${plugin.name}: Download link is up-to-date.`);
72+
console.log(\`✅ ${plugin.name}: Download link is up-to-date.\`);
7773
} else {
78-
console.error(`❌ ${plugin.name}: Download link is outdated.`);
79-
console.error(` Expected: ${latestDownloadUrl}`);
80-
console.error(` Found: ${releaseUrl}`);
81-
console.log(`::error file=badges.json,line=1::${plugin.name} has an outdated download link.`);
74+
console.error(\`❌ ${plugin.name}: Download link is outdated.\`);
75+
console.error(\` Expected: ${latestDownloadUrl}\`);
76+
console.error(\` Found: ${releaseUrl}\`);
77+
console.log(\`::error file=badges.json,line=1::${plugin.name} has an outdated download link.\`);
8278
hasErrors = true;
8379
}
8480
} catch (error) {
8581
if (error.response?.status === 404) {
86-
console.warn(`⚠️ ${plugin.name}: No releases found (404).`);
87-
console.log(`::warning file=badges.json,line=1::${plugin.name} has no releases.`);
82+
console.warn(\`⚠️ ${plugin.name}: No releases found (404).\`);
83+
console.log(\`::warning file=badges.json,line=1::${plugin.name} has no releases.\`);
8884
} else if (error.response?.status === 403) {
89-
console.error(`⚠️ ${plugin.name}: Rate limited or access denied (403).`);
90-
console.log(`::error file=badges.json,line=1::${plugin.name} encountered an access issue.`);
85+
console.error(\`⚠️ ${plugin.name}: Rate limited or access denied (403).\`);
86+
console.log(\`::error file=badges.json,line=1::${plugin.name} encountered an access issue.\`);
9187
hasErrors = true;
9288
} else {
93-
console.error(`⚠️ Error checking ${plugin.name}: ${error.message}`);
94-
console.log(`::error file=badges.json,line=1::${plugin.name} encountered an error: ${error.message}`);
89+
console.error(\`⚠️ Error checking ${plugin.name}: ${error.message}\`);
90+
console.log(\`::error file=badges.json,line=1::${plugin.name} encountered an error: ${error.message}\`);
9591
hasErrors = true;
9692
}
9793
}
@@ -103,7 +99,8 @@ jobs:
10399
}
104100
105101
validateLinks().catch(err => {
106-
console.error("Unhandled error:", err.message);
102+
console.error('Unhandled error:', err.message);
107103
process.exit(1);
108104
});
109-
EOF
105+
" > validate.js
106+
node validate.js

0 commit comments

Comments
 (0)