-
Notifications
You must be signed in to change notification settings - Fork 59
70 lines (59 loc) · 1.85 KB
/
validate.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: HTML Proofer
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 20
- name: Install dependencies
run: |
[ -f package.json ] && npm ci || npm init -y
npm install puppeteer http-server
- name: Serve files and render dynamic HTML using Puppeteer
run: |
npx http-server -p 8080 &
SERVER_PID=$!
sleep 5
for file in $(find . -maxdepth 1 -iname "*.html" ! -iname "*.partial.html"); do
echo "Processing file: ${file:2}"
output_file=$file
node -e "const puppeteer = require('puppeteer');
(async () => {
const url = 'http://localhost:8080/${file:2}';
const browser = await puppeteer.launch({
headless: 'new'
});
const page = await browser.newPage();
await page.goto(url, {waitUntil: 'networkidle0'});
const html = await page.content();
await browser.close();
const fs = require('fs');
fs.writeFileSync('$output_file', html);
})().catch(err => {
console.error('Error processing file:', err);
process.exit(1);
});"
done
kill $SERVER_PID
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
- name: Install HTML Proofer
run: gem install html-proofer
- name: Run HTML Proofer
run: |
for file in $(find . -maxdepth 1 -iname "*.html" ! -iname "*.partial.html"); do
htmlproofer $file --disable-external
done