-
-
Notifications
You must be signed in to change notification settings - Fork 800
55 lines (49 loc) · 1.59 KB
/
url-checker.yml
File metadata and controls
55 lines (49 loc) · 1.59 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
name: URL Checker
on:
pull_request:
paths:
- '5.0/**'
push:
branches:
- master
paths:
- '5.0/**'
workflow_dispatch:
jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
- name: Install markdown-link-check
run: npm i -g markdown-link-check@3.14.2
- name: Determine files to check
id: files
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
git diff --name-only --diff-filter=AM origin/${{ github.base_ref }} -- 5.0/ | grep '\.md$' > /tmp/files_to_check.txt || true
echo "mode=modified" >> $GITHUB_OUTPUT
else
find 5.0 -name '*.md' -not -path './node_modules/*' > /tmp/files_to_check.txt
echo "mode=all" >> $GITHUB_OUTPUT
fi
echo "Checking files (mode: $(cat $GITHUB_OUTPUT | grep mode | cut -d= -f2)):"
cat /tmp/files_to_check.txt
- name: Check URLs
run: |
ERROR_FOUND=0
while IFS= read -r file; do
if [ -n "$file" ]; then
markdown-link-check "$file" --config .github/workflows/config/url-checker-config.json -q || ERROR_FOUND=1
fi
done < /tmp/files_to_check.txt
if [ "$ERROR_FOUND" -eq 1 ]; then
echo ""
echo "ERROR: Dead links were found!"
exit 1
else
echo ""
echo "All links are good!"
fi