-
Notifications
You must be signed in to change notification settings - Fork 1
57 lines (52 loc) · 1.97 KB
/
Copy pathlink-check.yml
File metadata and controls
57 lines (52 loc) · 1.97 KB
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
name: Check internal links
on:
push:
branches: ["main"]
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: "link-check-${{ github.ref }}"
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
link-check:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.161.1
HTMLTEST_VERSION: 0.17.0
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Checkout
uses: actions/checkout@v7
with:
submodules: recursive
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
# Build with a root-relative baseURL so every in-site link resolves against
# ./public and can be checked on disk, with no server or network needed.
- name: Build with Hugo
env:
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
HUGO_ENVIRONMENT: production
run: hugo --minify --gc --baseURL "/"
- name: Install htmltest
run: |
wget -O ${{ runner.temp }}/htmltest.tar.gz \
"https://github.com/wjdp/htmltest/releases/download/v${HTMLTEST_VERSION}/htmltest_${HTMLTEST_VERSION}_linux_amd64.tar.gz"
tar -xzf ${{ runner.temp }}/htmltest.tar.gz -C ${{ runner.temp }} htmltest
sudo install ${{ runner.temp }}/htmltest /usr/local/bin/htmltest
- name: Check internal links
run: htmltest
# htmltest only inspects a[href], img[src], script[src] and link[href].
# The JS-driven nav (<option value>) and retina variants (srcset) fall
# outside those attributes, so they are checked separately.
- name: Check links htmltest does not cover
if: always()
run: python3 scripts/check-unchecked-links.py public