Skip to content

Commit

Permalink
flow to show only broken and not found links
Browse files Browse the repository at this point in the history
  • Loading branch information
Khushalsarode committed Oct 27, 2024
1 parent e01b6ee commit a20e33a
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/docs_link_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,29 @@ jobs:
- name: Run Sphinx linkcheck
run: |
cd docs
sphinx-build -b linkcheck source _build/linkcheck || true # link from source docs to be checked
grep "Not Found for url" _build/linkcheck/output.txt > broken_links.txt #output of broken links to broken_links.txt from _builds/linkcheck/output.txt
sphinx-build -b linkcheck source _build/linkcheck > /dev/null 2>&1 || true # Suppress full output of the sphinx-build -b linkcheck source _build/linkcheck command and redirect the output to /dev/null
# Extract broken links
grep "broken" _build/linkcheck/output.txt > broken_links.txt # Using Grep Extract broken links from the output.txt file and save them to broken_links.txt
grep "Not Found for url" _build/linkcheck/output.txt > not_found_links.txt # Using Grep Extract 'Not Found for url' links from the output.txt file and save them to not_found_links.txt
# -s flag checks if the file is not empty
# Display broken links if found
if [ -s broken_links.txt ]; then
echo "Broken links found:"
cat broken_links.txt
fi
# Display 'Not Found for url' links if found
if [ -s not_found_links.txt ]; then
echo "Not Found for url:"
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
exit 1
else
echo "No broken links found."
fi
fi

0 comments on commit a20e33a

Please sign in to comment.