Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow to check links in markdown files #499

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3fd136b
#419 Add GitHub Action to Check for Dead Links in Documentation
Khushalsarode Oct 18, 2024
527497e
#fixing the flow to check broken doc links
Khushalsarode Oct 19, 2024
f1a6d92
flow removed run with uses
Khushalsarode Oct 19, 2024
97f85c3
flow update for only broken link
Khushalsarode Oct 20, 2024
0a2b085
flow update for only broken link 1
Khushalsarode Oct 20, 2024
630503f
flow update for only broken link 2
Khushalsarode Oct 20, 2024
74fdde1
flow update for only broken link 3
Khushalsarode Oct 20, 2024
0ac7592
flow update for only broken link 4
Khushalsarode Oct 20, 2024
80f09c4
flow update for only broken link 5
Khushalsarode Oct 20, 2024
717a829
flow update for only broken link 6
Khushalsarode Oct 20, 2024
3077833
flow update for only broken link 7
Khushalsarode Oct 20, 2024
f4ec7b7
flow update for only broken link fix
Khushalsarode Oct 20, 2024
31d23ae
flow update for only broken link removed unwanted comments and format…
Khushalsarode Oct 20, 2024
e01b6ee
checking only for Not found url and exit
Khushalsarode Oct 26, 2024
a20e33a
flow to show only broken and not found links
Khushalsarode Oct 27, 2024
8a4743f
flow to show only broken and not found, easy to understand
Khushalsarode Oct 27, 2024
4ef0305
adding markdownflow to check links
Khushalsarode Oct 28, 2024
f7be0df
adding markdownflow to check links changednode version to 18
Khushalsarode Oct 28, 2024
e7808bb
adding markdownflow to check links ignored the flow for skip internal…
Khushalsarode Oct 28, 2024
d363ae9
adding markdownflow to check 1
Khushalsarode Oct 28, 2024
e86cbaa
adding markdownflow to check links 2
Khushalsarode Oct 28, 2024
721c187
adding markdownflow to check links changedto if loop
Khushalsarode Oct 28, 2024
b79ea9c
adding markdownflow to check links minor display adjusment
Khushalsarode Oct 28, 2024
b151712
adding markdownflow to check links final adjusment and fixing!
Khushalsarode Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/.markdown-link-check.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ignorePatterns": [
{
"pattern": "^#"
}
]
}

72 changes: 72 additions & 0 deletions .github/workflows/docs_link_check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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]
types: [opened, reopened, synchronize]

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 #upgrading pip
pip install -r docs/requirements.txt #installing the required packages from repo docs/requirements.txt
echo "Dependencies installed."

# Run Sphinx linkcheck to check for broken URLs
- name: Run Sphinx linkcheck
run: |
cd docs
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 "==============================="
echo "Broken links found:"
echo "==============================="
cat broken_links.txt
fi


# Display 'Not Found for url' links if found
if [ -s not_found_links.txt ]; then
echo "==============================="
echo "Not Found for url:"
echo "==============================="
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 "!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Broken links found."
echo "!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1

else
echo "#########################"
echo "No broken links found."
echo "#########################"
fi
48 changes: 48 additions & 0 deletions .github/workflows/markdown_files_link_check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Check Markdown Links

on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, reopened, synchronize]

jobs:
markdown-link-check:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3

# Set up Node.js (required for markdown-link-check)
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

# Install markdown-link-check
- name: Install markdown-link-check
run: |
npm install -g markdown-link-check

- name: Verify config file exists
run: |
ls -la .github/workflows/.markdown-link-check.json
cat .github/workflows/.markdown-link-check.json

# Check links in all Markdown files
- name: Check links in Markdown files
run: |
# Find all .md files and check their links
find . -name "*.md" | while read file; do
echo -------------------------------------
if [ markdown-link-check "$file" -c .github/workflows/.markdown-link-check.json -q ]; then
echo "Checking $file"
echo "$file contains broken links"
else
echo "$file contains no broken links"
fi
echo -------------------------------------
done
Loading