Skip to content

Commit a110335

Browse files
committed
feat: add broken link check
Signed-off-by: Bird <aflybird0@gmail.com>
1 parent 7bb19a5 commit a110335

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

.github/workflows/link-pr.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: links when pr
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
paths:
7+
- '**.md'
8+
- '.lycheeignore'
9+
10+
jobs:
11+
linkChecker:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Setup Hugo
17+
uses: peaceiris/actions-hugo@v2
18+
with:
19+
hugo-version: "latest"
20+
21+
- name: Build
22+
run: hugo --minify
23+
24+
- name: Link Checker
25+
uses: lycheeverse/lychee-action@v1.5.0
26+
with:
27+
fail: true
28+
# For parameter description, see https://github.com/lycheeverse/lychee#commandline-parameters
29+
# -E, --exclude-all-private Exclude all private IPs from checking.
30+
# -i, --insecure Proceed for server connections considered insecure (invalid TLS)
31+
# -n, --no-progress Do not show progress bar.
32+
# -t, --timeout <timeout> Website timeout in seconds from connect to response finished [default:20]
33+
# --max-concurrency <max-concurrency> Maximum number of concurrent network requests [default: 128]
34+
# -a --accept <accept> Comma-separated list of accepted status codes for valid links
35+
36+
# ./site the MkDocs site directory to check
37+
# ./*.md all markdown files in the root directory
38+
args: -E -i -n -t 45 --max-concurrency 64 -a 429,401 -- 'public' '*.md'
39+
env:
40+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/link.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: links
2+
3+
on:
4+
repository_dispatch:
5+
workflow_dispatch:
6+
schedule:
7+
- cron: "30 8 * * *"
8+
9+
jobs:
10+
linkChecker:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Download Exclude Path
16+
run: |
17+
curl https://raw.githubusercontent.com/gocn/How-To-Code-in-Go/main/.lycheeignore --output .lycheeignore
18+
19+
- name: Setup Hugo
20+
uses: peaceiris/actions-hugo@v2
21+
with:
22+
hugo-version: "latest"
23+
24+
- name: Build
25+
run: hugo --minify
26+
27+
- name: Check Links
28+
uses: lycheeverse/lychee-action@v1.5.0
29+
with:
30+
# For parameter description, see https://github.com/lycheeverse/lychee#commandline-parameters
31+
# -E, --exclude-all-private Exclude all private IPs from checking.
32+
# -v, --verbose Verbose program output
33+
# -i, --insecure Proceed for server connections considered insecure (invalid TLS)
34+
# -n, --no-progress Do not show progress bar.
35+
# -t, --timeout <timeout> Website timeout in seconds from connect to response finished [default:20]
36+
# --max-concurrency <max-concurrency> Maximum number of concurrent network requests [default: 128]
37+
# -a --accept <accept> Comma-separated list of accepted status codes for valid links
38+
39+
# ./site the MkDocs site directory to check
40+
# ./*.md all markdown files in the root directory
41+
args: -E -v -i -n -t 45 --max-concurrency 64 -a 429,401 -- 'public' '*.md'
42+
output: out.md
43+
env:
44+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
45+
46+
- name: Create Issue From File
47+
uses: peter-evans/create-issue-from-file@v3
48+
with:
49+
title: Broken Link Detected
50+
content-filepath: out.md
51+
# assignees: aFlyBird0

.lycheeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)