diff --git a/.github/workflows/docs_link_check.yaml b/.github/workflows/docs_link_check.yaml index 31b3fd88..00ffd6a9 100644 --- a/.github/workflows/docs_link_check.yaml +++ b/.github/workflows/docs_link_check.yaml @@ -17,29 +17,30 @@ jobs: - name: Set up Python 3.x uses: actions/setup-python@v4 with: - python-version: "3.x" + python-version: '3.x' + - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install -r docs/requirements.txt + python -m pip install --upgrade pip + pip install -r docs/requirements.txt echo "Dependencies installed." - name: Run Sphinx linkcheck run: | cd docs - sphinx-build -b linkcheck source _build/linkcheck > /dev/null 2>&1 || true # Suppress full output + sphinx-build -b linkcheck source _build/linkcheck > /dev/null 2>&1 || true + grep "broken" _build/linkcheck/output.txt > broken_links.txt + grep "Not Found for url" _build/linkcheck/output.txt > not_found_links.txt - grep "broken" _build/linkcheck/output.txt > broken_links.txt # Extract broken links - grep "Not Found for url" _build/linkcheck/output.txt > not_found_links.txt # Extract not found links - - # -s flag checks if the file is not empty. + if [ -s broken_links.txt ]; then echo "============" - echo "Broken Links" + echo "Broken links" echo "============" cat broken_links.txt fi + if [ -s not_found_links.txt ]; then echo "===============" @@ -48,7 +49,6 @@ jobs: cat not_found_links.txt fi - # Exit with error if any broken or not found links exist if [ -s broken_links.txt ] || [ -s not_found_links.txt ]; then echo "Broken links found." exit 1