From 5e622d8555b15fae833a4b4e0350b5620edfb583 Mon Sep 17 00:00:00 2001 From: Khushalsarode Date: Sat, 19 Oct 2024 02:44:43 +0530 Subject: [PATCH] #419 Add GitHub Action to Check for Dead Links in Documentation --- .github/workflows/docs_broken_linkcheck.yaml | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/docs_broken_linkcheck.yaml diff --git a/.github/workflows/docs_broken_linkcheck.yaml b/.github/workflows/docs_broken_linkcheck.yaml new file mode 100644 index 000000000..033b950d2 --- /dev/null +++ b/.github/workflows/docs_broken_linkcheck.yaml @@ -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