-
Notifications
You must be signed in to change notification settings - Fork 5
109 lines (94 loc) · 3.26 KB
/
proof-links.yml
File metadata and controls
109 lines (94 loc) · 3.26 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Proof Links
on: [pull_request, workflow_dispatch]
env:
HUGO_VERSION: 0.147.8
LYCHEE_RELEASE: "lychee-v0.15.1-x86_64-unknown-linux-gnu.tar.gz"
LYCHEE_VERSION_TAG: "v0.15.1"
jobs:
proof-links:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: ${{ env.HUGO_VERSION }}
extended: true
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache Hugo Modules
uses: actions/cache@v4
with:
path: /tmp/hugo_cache
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-hugomod-
- name: Install Dependencies
working-directory: site
run: npm ci
- name: Build Spine
working-directory: site
run: hugo -e development
# Cache Lychee results to avoid hitting rate limits.
- name: Cache Lychee results
uses: actions/cache@v4
with:
path: .lycheecache
key: cache-lychee-results
- name: Cache Lychee executable
id: cache-lychee
uses: actions/cache@v4
with:
path: lychee
key: ${{ runner.os }}-${{ env.LYCHEE_RELEASE }}
# We use Lychee directly instead of a GitHub Action because it
# must have access the local Hugo server, which is not visible
# from the Docker-based action.
- name: Download Lychee executable
uses: robinraju/release-downloader@v1.7
if: steps.cache-lychee.outputs.cache-hit != 'true'
with:
repository: "lycheeverse/lychee"
tag: ${{ env.LYCHEE_VERSION_TAG }}
fileName: ${{ env.LYCHEE_RELEASE }}
- name: Extract Lychee executable
if: steps.cache-lychee.outputs.cache-hit != 'true'
run: |
mkdir -p lychee &&
tar -xf ${{ env.LYCHEE_RELEASE }} -C lychee
# 1. In the generated HTML, some inner links will have absolute URLs and
# the link checker will attempt to fetch them. That's why we need
# a server. Sadly, link checkers have no settings to address this.
# 2. Output redirection is necessary for nohup in GitHub Actions.
# 3. Sleep makes sure the server is up before the next step.
- name: Start Hugo server
working-directory: site
run: |
nohup hugo server \
--environment development \
> nohup.out 2> nohup.err < /dev/null &
sleep 5
- name: Check if the cache file exists
run: |
if [ -f ".lycheecache" ]; then
echo "Lychee cache exists."
else
echo "No lychee cache file."
fi
- name: Check links
run: |
./lychee/lychee --config lychee.toml --timeout 60 \
--base http://localhost:1313/ \
'site/public/**/*.html'