This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 162
56 lines (46 loc) · 1.7 KB
/
valid-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
name: CI
on:
push:
pull_request:
workflow_dispatch:
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
verify-links:
name: Check for dead links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git fetch origin master
git merge origin/master
- name: Install .NET 5.0.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
- name: Install MarkdownLinkChecker
run: dotnet tool install -g markdownlinkchecker
- name: Verify links
run: |
deleted_or_renamed=$(git diff --no-commit-id --name-only --diff-filter DR origin/master | grep -i .md$ | grep -v -i _sidebar.md | grep -v -i ISSUE_TEMPLATE | wc -l)
if [ "${{ secrets.ACTIONS_STEP_DEBUG }}" = "true" ]; then
debug_level="detailed"
else
debug_level="minimal"
fi
if [ "$GITHUB_REF" = "refs/heads/master" ] || [[ $deleted_or_renamed -ne 0 ]]
then
echo "Searching all files..."
markdownlinkchecker -m files -v "$debug_level"
else
files=$(git diff --no-commit-id --name-only --diff-filter AM origin/master | grep -i .md$ | grep -v -i _sidebar.md | grep -v -i ISSUE_TEMPLATE | cat)
echo "Searching changed files: $files"
if [[ -n $files ]]; then
# shellcheck disable=SC2086
markdownlinkchecker -m files -v "$debug_level" -f $files
fi
fi