Skip to content

Update plugin-version-checker.yml #7

Update plugin-version-checker.yml

Update plugin-version-checker.yml #7

- name: Check Plugins
id: check-plugins

Check failure on line 2 in .github/workflows/plugin-version-checker.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/plugin-version-checker.yml

Invalid workflow file

You have an error in your yaml syntax on line 2
run: |
node -e "
const fs = require('fs');
const axios = require('axios');
try {
const readmePath = 'README.md';
const pluginsSectionStart = '<!-- START PLUGINS LIST -->';
const pluginsSectionEnd = '<!-- END PLUGINS LIST -->';
// Read the README file
const readmeContent = fs.readFileSync(readmePath, 'utf8');
// Extract the plugins section
const pluginSection = readmeContent.split(pluginsSectionStart)[1]?.split(pluginsSectionEnd)[0];
if (!pluginSection) {
console.error('Error: Plugins section not found in the README file.');
process.exit(1);
}
// Debug: Log the plugin section
console.log('Plugin Section:', pluginSection);
// Extract GitHub URLs from the plugin section
const pluginRegex = /https:\/\/github\.com\/([\w-]+)\/([\w-]+)/g;
const matches = [...pluginSection.matchAll(pluginRegex)];
const plugins = matches.map(match => ({ owner: match[1], repo: match[2] }));
// Debug: Log matches and plugins
console.log('Matches Found:', matches);
console.log('Parsed Plugins:', plugins);
if (plugins.length === 0) {
console.error('Error: No valid plugins found in the README file.');
process.exit(1);
}
// Function to check latest releases
async function checkPlugins(plugins) {
const results = [];
for (const { owner, repo } of plugins) {
if (!owner || !repo) {
console.warn(`Invalid plugin entry: owner=${owner}, repo=${repo}`);
results.push({ repo: `${owner}/${repo}`, status: 'Invalid Data' });
continue;
}
try {
const response = await axios.get(
`https://api.github.com/repos/${owner}/${repo}/releases/latest`,
{ headers: { Accept: 'application/vnd.github.v3+json' } }
);
const latestVersion = response.data.tag_name || 'No tag';
const releaseDate = response.data.published_at || 'Unknown';
results.push({ repo: `${owner}/${repo}`, latestVersion, releaseDate, status: 'Up-to-date' });
} catch (error) {
results.push({ repo: `${owner}/${repo}`, status: 'Error or No Releases Found', error: error.message });
}
}
return results;
}
// Run the check and display results
(async () => {
const results = await checkPlugins(plugins);
console.table(results);
const problematicPlugins = results.filter(result => result.status !== 'Up-to-date');
if (problematicPlugins.length > 0) {
console.error('Outdated or Problematic Plugins:', problematicPlugins);
process.exit(1);
} else {
console.log('All plugins are up-to-date.');
}
})().catch(err => {
console.error('Unexpected Error:', err);
process.exit(1);
});
} catch (err) {
console.error('Script Error:', err);
process.exit(1);
}
"