generated from koldovsky/html-template-autocheck
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0d4172b
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# HTML Template Repository with HTML Proofer | ||
|
||
This template repository includes preconfigured GitHub Action that will validate html files in a project with (HTMLProofer)[https://github.com/gjtorikian/html-proofer/]. | ||
|
||
Validation is performed with dynamic pre-rendering of html files so it will allow to construct them with JavaScript on the fly. | ||
|
||
HTML files with 'partial.html' suffix will be ignored, so validator is compatible with dynamic construction of website with html includes like (HTML Data Include)[https://github.com/programmingmentor/html-data-include]. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
<link rel="shortcut icon" href="https://placekitten.com/96/139" type="image/x-icon"> | ||
</head> | ||
<body> | ||
<script src="https://unpkg.com/[email protected]/html-data-include.js"></script> | ||
</body> | ||
</html> |