Add GitHub Action for Sphinx documentation link checking #3
Workflow file for this run
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
name: Link Checker for Sphinx Documentation | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
link-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Caching | |
- name: Set up Python 3.x | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r docs/requirements.txt # Install Sphinx and other dependencies | |
- name: Run Sphinx linkcheck | |
run: | | |
cd docs | |
sphinx-build -b linkcheck source _build/linkcheck | |
- name: Display and check linkcheck results | |
run: | | |
echo "Checking for broken links..." | |
cat _build/linkcheck/output.txt | |
if grep -q "broken" _build/linkcheck/output.txt; then | |
echo "Broken links detected!" | |
grep "broken" _build/linkcheck/output.txt | |
exit 1 | |
else | |
echo "No broken links found." |