π Automated Documentation Link Validation for General Projects
Standalone workflow for checking documentation links and ensuring all references are valid
π Overview
The Link Check Workflow is a standalone reusable workflow that validates all documentation links in your repository.
It ensures that all internal and external links are working correctly, preventing broken references in your documentation.
Key Features
π Comprehensive Link Checking - Validates all markdown files and documentation using Lychee
π External Link Validation - Checks external URLs for accessibility with retry logic
π Internal Link Validation - Verifies internal file references and anchors
β‘ Fast Processing - Efficient scanning with configurable timeouts and parallel processing
π― Flexible Path Patterns - Customizable file and directory patterns
π Detailed Reporting - Clear error messages and link status with verbose output
π‘οΈ Smart Filtering - Excludes private links and mailto addresses by default
π Retry Logic - Automatic retry for failed links with configurable attempts
name:Advanced Link Checkon:push:branches:[main]pull_request:branches:[main]jobs:link-check:uses:N3b3x/hf-general-ci-tools/.github/workflows/docs-link-check.yml@v1with:paths:"docs/***.md**/docs/**"fail_on_errors:truetimeout:"15"retry:"5"exclude_private:trueexclude_mail:trueverbose:true
Using TOML Configuration File
For advanced configuration, you can use a lychee.toml file:
1
2
3
4
5
6
7
8
9
10
11
12
13
name:Link Check with TOML Configon:push:branches:[main]jobs:link-check:uses:N3b3x/hf-general-ci-tools/.github/workflows/docs-link-check.yml@v1with:config_file:"lychee.toml"paths:"docs/***.md"verbose:true
Creating a TOML Config File:
Create a custom configuration file:
1
2
# Create lychee.toml in your repository roottouch lychee.toml
Then customize it for your needs. The TOML file allows you to:
Set default timeouts and retry counts
Exclude specific domains or patterns
Configure HTTP headers and redirects
Enable caching for faster subsequent runs
π Input Parameters
π File Selection
Parameter
Type
Default
Description
checkout_recursive
boolean
false
Checkout submodules recursively (for projects with docs in submodules)
paths
string
"docs/** *.md **/docs/**"
Space-separated paths to check for broken links
βοΈ Link Checking Configuration
Parameter
Type
Default
Description
timeout
string
"10"
Timeout in seconds for each link check
retry
string
"3"
Number of retries for failed links
exclude_private
boolean
true
Exclude private/internal links
exclude_mail
boolean
true
Exclude mailto links
config_file
string
""
Path to lychee.toml config file (optional)
π Output Control
Parameter
Type
Default
Description
fail_on_errors
boolean
true
Fail the workflow if broken links are found
verbose
boolean
false
Enable verbose output
Path Patterns
The paths parameter supports glob patterns:
docs/** - All files in docs directory and subdirectories
Important: Paths must be space-separated, not comma-separated, as required by lycheeverse/lychee-action@v2.
π§ Usage Examples
Basic Link Check
1
2
3
4
5
6
7
8
9
name:Basic Link Checkon:push:branches:[main]jobs:link-check:uses:N3b3x/hf-general-ci-tools/.github/workflows/docs-link-check.yml@v1
Custom Paths
1
2
3
4
5
6
7
8
9
10
11
12
name:Custom Link Checkon:push:branches:[main]jobs:link-check:uses:N3b3x/hf-general-ci-tools/.github/workflows/docs-link-check.yml@v1with:paths:"docs/**README.mdCONTRIBUTING.md"fail_on_errors:false
Documentation Only
1
2
3
4
5
6
7
8
9
10
11
name:Documentation Link Checkon:push:branches:[main]jobs:link-check:uses:N3b3x/hf-general-ci-tools/.github/workflows/docs-link-check.yml@v1with:paths:"docs/**"
All Markdown Files
1
2
3
4
5
6
7
8
9
10
11
name:All Markdown Link Checkon:push:branches:[main]jobs:link-check:uses:N3b3x/hf-general-ci-tools/.github/workflows/docs-link-check.yml@v1with:paths:"**/*.md"
With Submodule Support
1
2
3
4
5
6
7
8
9
10
11
12
13
14
name:Link Check with Submoduleson:push:branches:[main]jobs:link-check:uses:N3b3x/hf-general-ci-tools/.github/workflows/docs-link-check.yml@v1with:checkout_recursive:true# Enable submodule checkoutpaths:"docs/***.md**/docs/**"fail_on_errors:truetimeout:"15"
name:Full CI Pipelineon:push:branches:[main]pull_request:branches:[main]jobs:lint:uses:N3b3x/hf-general-ci-tools/.github/workflows/c-cpp-lint.yml@v1static:uses:N3b3x/hf-general-ci-tools/.github/workflows/c-cpp-static-analysis.yml@v1link-check:uses:N3b3x/hf-general-ci-tools/.github/workflows/docs-link-check.yml@v1docs:uses:N3b3x/hf-general-ci-tools/.github/workflows/docs.yml@v1
Symptoms: βTimeoutβ or βConnection timeoutβ errors
Solutions:
1
2
3
4
5
6
7
# Check if external site is accessible
ping example.com
# Verify network connectivity
curl -I https://example.com
# Check if site requires authentication
False Positives
Symptoms: Valid links reported as broken
Solutions:
1
2
3
4
5
6
7
8
# Check link formatecho"https://example.com/path"# Verify file encoding
file -i docs/file.md
# Check for special charactersgrep-n"\[.*\](.*)" docs/file.md
Debug Mode
Enable verbose output for debugging:
1
2
3
4
5
6
jobs:link-check:uses:N3b3x/hf-general-ci-tools/.github/workflows/docs-link-check.yml@v1with:paths:"docs/**"fail_on_errors:false# Don't fail on errors for debugging