Skip to content

Commit 8e0ff1a

Browse files
committed
feat: add link checker
1 parent f090d83 commit 8e0ff1a

File tree

3 files changed

+270
-3
lines changed

3 files changed

+270
-3
lines changed

.github/workflows/link-checker.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Link Checker
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
schedule:
8+
- cron: "0 2 * * *"
9+
10+
jobs:
11+
check-internal:
12+
runs-on: ubuntu-latest
13+
if: github.event_name != 'schedule'
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: pnpm/action-setup@v4
18+
with:
19+
version: 9
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 20
25+
cache: pnpm
26+
27+
- name: Install dependencies
28+
run: pnpm install --frozen-lockfile
29+
30+
- name: Build and start
31+
run: pnpm next build && pnpm next start &
32+
33+
- name: Wait for server
34+
run: sleep 5
35+
36+
- name: Check internal links
37+
run: pnpm linkinator http://localhost:3000 --recurse --skip "^(?!http://localhost)"
38+
39+
check-external:
40+
runs-on: ubuntu-latest
41+
if: github.event_name == 'schedule'
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- uses: pnpm/action-setup@v4
46+
with:
47+
version: 9
48+
49+
- name: Setup Node.js
50+
uses: actions/setup-node@v4
51+
with:
52+
node-version: 20
53+
cache: pnpm
54+
55+
- name: Install dependencies
56+
run: pnpm install --frozen-lockfile
57+
58+
- name: Build and start
59+
run: pnpm next build && pnpm next start &
60+
61+
- name: Wait for server
62+
run: sleep 5
63+
64+
- name: Check all links
65+
run: pnpm linkinator http://localhost:3000 --recurse
66+
67+
- name: Notify Slack on failure
68+
if: failure()
69+
run: |
70+
curl -X POST ${{ secrets.SLACK_WEBHOOK_URL }} \
71+
-H 'Content-type: application/json' \
72+
-d '{"text": "🔴 Dead links detected in nightly link check. <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View run>"}'

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"eslint-config-prettier": "^9.1.0",
7373
"eslint-plugin-react": "^7.37.4",
7474
"eslint-plugin-tailwindcss": "^3.18.0",
75+
"linkinator": "^7.6.1",
7576
"postcss": "^8.5.1",
7677
"prettier": "^3.4.2",
7778
"prettier-plugin-tailwindcss": "^0.6.11",

0 commit comments

Comments
 (0)