-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#419 Add GitHub Action to Check for Dead Links in Documentation
- Loading branch information
1 parent
02c7e1b
commit 5e622d8
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Link Checker for Sphinx Documentation | ||
# Trigger the workflow on push to main branch or pull request to main branch | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
link-check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout the repository | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
# Set up Python | ||
- name: Set up Python 3.x | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
# Install dependencies | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r docs/requirements.txt | ||
pip install sphinx-linkcheck | ||
# Run Sphinx linkcheck to check for broken URLs | ||
- name: Run Sphinx linkcheck | ||
run: | | ||
cd docs | ||
sphinx-build -b linkcheck source _build/linkcheck # link from source docs to be checked | ||
# Display linkcheck results and fail on broken links | ||
- name: Display linkcheck results | ||
run: | | ||
cat _build/linkcheck/output.txt | ||
# Check if the output contains "broken" & list the broken links | ||
if grep -q "broken" _build/linkcheck/output.txt; then | ||
echo "Broken links detected!" | ||
exit 1 # Fail the job if broken links are found | ||
else | ||
echo "No broken links found." | ||
fi |