Skip to content

Update check-latest-release.yml #5

Update check-latest-release.yml

Update check-latest-release.yml #5

name: Check Latest Release URLs
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
check-readme:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install @octokit/rest
- name: Check README for latest release URLs
run: node <<EOF
const fs = require('fs');
const { Octokit } = require('@octokit/rest');
const octokit = new Octokit(); // Unauthenticated for public API calls
const readme = fs.readFileSync('README.md', 'utf-8');
// Regular expression to match plugin name, repo URL, and release URL
const regex = /- (.*?) \(https:\\/\\/github\\.com\\/.*?)\.*?\(.*?)\\(https:\\/\\/github\\.com\\/.*?\\/releases\\/.*)\/g;
let match;
let allCorrect = true;
console.log('Checking README for outdated release URLs...');
while ((match = regex.exec(readme)) !== null) {
const pluginName = match[1];
const repoUrl = match[2];
const currentReleaseUrl = match[4];
const repoPath = repoUrl.replace('https://github.com/', '');
try {
const { data: latestRelease } = await octokit.repos.getLatestRelease({

Check failure on line 49 in .github/workflows/check-latest-release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/check-latest-release.yml

Invalid workflow file

You have an error in your yaml syntax on line 49
owner: repoPath.split('/')[0],
repo: repoPath.split('/')[1],
});
const latestReleaseUrl = latestRelease.html_url;
if (currentReleaseUrl !== latestReleaseUrl) {
console.log(`❌ ${pluginName} is outdated. Update the URL to ${latestReleaseUrl}`);
allCorrect = false;
} else {
console.log(`✅ ${pluginName} is up-to-date.`);
}
} catch (error) {
console.log(`⚠️ Failed to fetch latest release for ${pluginName}. Error: ${error.message}`);
allCorrect = false;
}
}
if (!allCorrect) {
process.exit(1); // Exit with error code if any plugin is outdated
}
EOF