Skip to content

Update check-latest-release.yml #13

Update check-latest-release.yml

Update check-latest-release.yml #13

name: Check Latest Release URLs
on:
push:
branches:
- main
workflow_dispatch:
jobs:
check-readme:
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm install @octokit/rest
- name: Check README for outdated release URLs
run: |
node --input-type=module <<'EOF'
import { readFileSync } from 'fs';
import { Octokit } from '@octokit/rest';
const octokit = new Octokit(); // Unauthenticated for public API calls
const checkLatestRelease = async () => {
const readme = readFileSync('README.md', 'utf-8');
const regex = /- ### (.*?)(https:\/\/github\.com\/.*?).*?.*?(https:\/\/github\.com\/.*?\/releases\/.*?)/g;
let match;
let allCorrect = true;
console.log('🔍 Starting checks for outdated release URLs in README...');
while ((match = regex.exec(readme)) !== null) {
const pluginName = match[1];
const repoUrl = match[2];
const currentReleaseUrl = match[3];
const repoPath = repoUrl.replace('https://github.com/', '');
console.log(`\n🛠 Checking plugin: ${pluginName}`);
console.log(` ➤ Repository URL: ${repoUrl}`);
console.log(` ➤ Current Release URL: ${currentReleaseUrl}`);
try {
const { data: latestRelease } = await octokit.repos.getLatestRelease({
owner: repoPath.split('/')[0],
repo: repoPath.split('/')[1],
});
const latestReleaseUrl = latestRelease.html_url;
console.log(` ➤ Latest Release URL: ${latestReleaseUrl}`);
if (currentReleaseUrl === latestReleaseUrl) {
console.log(`✅ ${pluginName} is up-to-date.`);
} else {
console.log(`❌ ${pluginName} is outdated. Update the URL to ${latestReleaseUrl}`);
console.log(`::warning file=README.md::${pluginName} is outdated. Update the URL to ${latestReleaseUrl}`);
allCorrect = false;
}
} catch (error) {
console.error(`⚠️ Failed to fetch latest release for ${pluginName}. Error: ${error.message}`);
console.log(`::error file=README.md::Failed to fetch latest release for ${pluginName}: ${error.message}`);
allCorrect = false;
}
}
console.log(
`\n${allCorrect ? '✅ All plugins are up-to-date.' : '❌ Some plugins are outdated.'}`
);
if (!allCorrect) {
process.exit(1);
}
};
checkLatestRelease();
EOF