revert: gh workflow/validation - already covered by building
This commit is contained in:
parent
66360b9c7a
commit
f2acf36784
4 changed files with 2 additions and 72 deletions
25
.github/workflows/validate.yml
vendored
25
.github/workflows/validate.yml
vendored
|
|
@ -1,25 +0,0 @@
|
||||||
name: Validate content
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- 'www/content/**'
|
|
||||||
- 'www/public/*.txt'
|
|
||||||
- 'www/public/config.yaml'
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- 'www/content/**'
|
|
||||||
- 'www/public/*.txt'
|
|
||||||
- 'www/public/config.yaml'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
validate:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: pnpm/action-setup@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 22
|
|
||||||
cache: pnpm
|
|
||||||
- run: pnpm install --frozen-lockfile
|
|
||||||
- run: pnpm validate:www
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
"dev:penfield": "pnpm --filter @ily/penfield dev",
|
"dev:penfield": "pnpm --filter @ily/penfield dev",
|
||||||
"dev:www": "pnpm --filter @ily/www dev",
|
"dev:www": "pnpm --filter @ily/www dev",
|
||||||
"build:penfield": "pnpm --filter @ily/penfield build",
|
"build:penfield": "pnpm --filter @ily/penfield build",
|
||||||
"build:www": "pnpm --filter @ily/www build",
|
"build:www": "pnpm --filter @ily/www build"
|
||||||
"validate:www": "pnpm --filter @ily/www validate"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@
|
||||||
"dev": "astro dev --port 4322",
|
"dev": "astro dev --port 4322",
|
||||||
"build": "astro build --remote && node scripts/generate-stats.js",
|
"build": "astro build --remote && node scripts/generate-stats.js",
|
||||||
"preview": "astro preview",
|
"preview": "astro preview",
|
||||||
"serve": "pnpm build && npx serve .vercel/output/static -l 4322",
|
"serve": "pnpm build && npx serve .vercel/output/static -l 4322"
|
||||||
"validate": "node scripts/validate-content.js"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/db": "^0.19.0",
|
"@astrojs/db": "^0.19.0",
|
||||||
|
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
import fs from 'node:fs';
|
|
||||||
import path from 'node:path';
|
|
||||||
import yaml from 'js-yaml';
|
|
||||||
|
|
||||||
const root = path.resolve(import.meta.dirname, '..');
|
|
||||||
const contentDir = path.join(root, 'content');
|
|
||||||
const publicDir = path.join(root, 'public');
|
|
||||||
const errors = [];
|
|
||||||
|
|
||||||
const mdFiles = fs.readdirSync(contentDir).filter(f => f.endsWith('.md'));
|
|
||||||
for (const file of mdFiles) {
|
|
||||||
const content = fs.readFileSync(path.join(contentDir, file), 'utf8');
|
|
||||||
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
||||||
if (!match) {
|
|
||||||
errors.push(`${file}: missing frontmatter`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const frontmatter = match[1];
|
|
||||||
if (!/^date:\s*.+/m.test(frontmatter)) {
|
|
||||||
errors.push(`${file}: missing required 'date' field`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const configPath = path.join(publicDir, 'config.yaml');
|
|
||||||
const config = fs.existsSync(configPath)
|
|
||||||
? yaml.load(fs.readFileSync(configPath, 'utf8'))
|
|
||||||
: {};
|
|
||||||
const configDates = config.dates || {};
|
|
||||||
const txtFiles = fs.readdirSync(publicDir).filter(f => f.endsWith('.txt'));
|
|
||||||
for (const file of txtFiles) {
|
|
||||||
if (!configDates[file]) {
|
|
||||||
errors.push(`${file}: missing date in config.yaml`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errors.length) {
|
|
||||||
console.error('Content validation failed:\n');
|
|
||||||
for (const err of errors) console.error(` - ${err}`);
|
|
||||||
console.error('');
|
|
||||||
process.exit(1);
|
|
||||||
} else {
|
|
||||||
console.log(`Validated ${mdFiles.length} posts and ${txtFiles.length} txt files.`);
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue