1- name : Links
1+ name : Check external URLs in all files
22
33on :
44 repository_dispatch :
55 workflow_dispatch :
66 schedule :
77 - cron : " 0 0 * * 1"
88
9+ env :
10+ DOCS_SITE_BASE_URL : " https://docs.pingcap.com"
11+
12+ permissions :
13+ contents : read
14+ issues : write
15+
916jobs :
1017 linkChecker :
1118 runs-on : ubuntu-latest
@@ -14,20 +21,69 @@ jobs:
1421
1522 - name : Download Exclude Path
1623 run : |
17- curl https://raw.githubusercontent.com/pingcap/docs/master/.lycheeignore --output .lycheeignore
24+ curl -fsSL https://raw.githubusercontent.com/pingcap/docs/master/.lycheeignore --output .lycheeignore
1825
1926 - name : Check Links
2027 uses : lycheeverse/lychee-action@v1.6.1
2128 with :
2229 # Don't fail as we want the workflow to continue and run 'Create Issue From File'
23- # Excluding releases paths as historic releases may have outdated links.
2430 fail : false
2531 failIfEmpty : false
26- args : --root-dir $(pwd) --cache --max-cache-age 8d -E -i -n -t 45 --exclude-path '^./releases/' --exclude-path '^./tidb-cloud/releases/' --exclude-path '^./resources/' .
27- output : out.md
32+ args : --root-dir $(pwd) --cache --max-cache-age 8d --cache-exclude-status '..200,300..' --exclude '^file://' -E -i -n -t 45 --exclude-path '^\./releases/' --exclude-path '^\./tidb-cloud/releases/' --exclude-path '^\./resources/' .
33+ output : out-external.md
34+ env :
35+ GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
36+
37+ - name : Collect doc site href URLs
38+ id : site-hrefs
39+ run : |
40+ git ls-files -z -- \
41+ '*.md' '*.mdx' '*.markdown' '*.mkd' '*.mdown' '*.mdwn' '*.mkdn' '*.mkdown' \
42+ '*.html' '*.htm' '*.css' '*.txt' |
43+ perl -0ne 'print unless m{^(?:releases|tidb-cloud/releases|resources)/}' |
44+ perl .github/scripts/extract-site-hrefs.pl .lychee-site-hrefs .lychee-site-href-files.txt
45+
46+ count=$(wc -l < .lychee-site-href-files.txt | tr -d ' ')
47+ echo "count=${count}" >> "$GITHUB_OUTPUT"
48+
49+ if [ "$count" -gt 0 ]; then
50+ echo "has_hrefs=true" >> "$GITHUB_OUTPUT"
51+ sed 's/^/- /' .lychee-site-href-files.txt
52+ else
53+ echo "has_hrefs=false" >> "$GITHUB_OUTPUT"
54+ fi
55+
56+ - name : Check site href URLs
57+ if : ${{ steps.site-hrefs.outputs.has_hrefs == 'true' }}
58+ uses : lycheeverse/lychee-action@v2
59+ with :
60+ # Don't fail as we want the workflow to continue and run 'Create Issue From File'
61+ fail : false
62+ failIfEmpty : false
63+ args : --cache --max-cache-age 8d --cache-exclude-status '..200,300..' -E -i -n -t 45 --files-from .lychee-site-href-files.txt
64+ output : out-site-hrefs.md
2865 env :
2966 GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
3067
68+ - name : Combine Link Reports
69+ run : |
70+ {
71+ echo "# External URL Check"
72+ echo
73+ if [ -f out-external.md ]; then
74+ cat out-external.md
75+ else
76+ echo "*(external link check did not produce output)*"
77+ fi
78+
79+ if [ -f out-site-hrefs.md ]; then
80+ echo
81+ echo "# Site href URL Check"
82+ echo
83+ cat out-site-hrefs.md
84+ fi
85+ } > out.md
86+
3187 - name : Create Issue From File
3288 uses : peter-evans/create-issue-from-file@v4
3389 with :
0 commit comments