Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add markdown link checker #60

Merged
merged 3 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/scripts/markdown-link-check-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"retryOn429": true,
"aliveStatusCodes": [
200,
403
],
"ignorePatterns": []
}
17 changes: 17 additions & 0 deletions .github/scripts/markdown-link-check-with-retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -e

# this script helps to reduce sporadic link check failures by retrying at a file-by-file level

retry_count=3

for file in "$@"; do
for i in $(seq 1 $retry_count); do
if markdown-link-check --config "$(dirname "$0")/markdown-link-check-config.json" \
"$file"; then
break
elif [[ $i -eq $retry_count ]]; then
exit 1
fi
sleep 5
done
done
5 changes: 5 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ jobs:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}

markdown-link-check:
# release branches are excluded to avoid unnecessary maintenance
if: ${{ !startsWith(github.ref_name, 'release/') }}
uses: ./.github/workflows/reusable-markdown-link-check.yml

workflow-notification:
needs:
- build
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/reusable-markdown-link-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Reusable - Markdown link check

on:
workflow_call:

jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install markdown-link-check
run: npm install -g markdown-link-check

- name: Run markdown-link-check
run: |
find . -type f \
-name '*.md' \
-not -path './CHANGELOG.md' \
| xargs .github/scripts/markdown-link-check-with-retry.sh