Skip to content

Commit

Permalink
scribe-org#419 Add GitHub Action to Check for Dead Links in Documenta…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Khushalsarode committed Oct 18, 2024
1 parent 02c7e1b commit 5e622d8
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/docs_broken_linkcheck.yaml
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

0 comments on commit 5e622d8

Please sign in to comment.