-
Notifications
You must be signed in to change notification settings - Fork 3
89 lines (77 loc) · 2.38 KB
/
reusable-docs-links.yml
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
name: Check links
on:
workflow_call:
inputs:
docs-path:
description: 'The path to the docs to check'
type: string
default: 'build/site'
skipfile:
description: 'The path to the skipfile'
type: string
default: '.docs-tools/link-checker/ignore-links.txt'
retain-artifacts:
description: 'The number of days to retain artifacts'
type: number
default: 7
workflow_dispatch:
inputs:
docs-path:
description: 'The path to the docs to check'
type: string
default: 'build/site'
skipfile:
description: 'The path to the skipfile'
type: string
default: '.docs-tools/link-checker/ignore-links.txt'
retain-artifacts:
description: 'The number of days to retain artifacts'
type: number
default: 7
jobs:
check-links:
runs-on: ubuntu-latest
env:
DOCS_PATH: ${{ inputs.docs-path }}
SKIPFILE: ${{ inputs.skipfile }}
steps:
- name: Checkout tools repo
uses: actions/checkout@v4
with:
repository: neo4j/docs-tools
ref: dev
sparse-checkout: |
link-checker
path: .docs-tools
- name: Download HTML
uses: actions/[email protected]
with:
name: docs
path: build
- name: Use Node.js lts
uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install link checker
run: npm install github:recrwplay/link-checker#v0.2.0
- name: Run link checker
run: |
npx link-checker $DOCS_PATH --skip-file $SKIPFILE -e |& tee link-log.txt
warncount=$(grep -e "[0-9]* warnings" -o link-log.txt | sed 's/ warnings//' )
if [ $warncount -gt 0 ]; then
echo "::warning:: $warncount warnings"
fi
errorcount=$(grep -e "[0-9]* errors" -o link-log.txt | sed 's/ errors//' )
if [ $errorcount -gt 0 ]; then
echo "::error:: Errors found: See the output of the Check links step for details"
exit 1
fi
# upload artifacts
- name: Save log
uses: actions/upload-artifact@v4
with:
name: linklog
path: link-log.txt
# if errors, raise an issue in the repo and exit 1 to fail the workflow
# tbc...
# create an action. action needs authed token. attach log to issue. extract errors as issue text?