Skip to content

Update broken-links.yml #56

Update broken-links.yml

Update broken-links.yml #56

Workflow file for this run

name: Check README for Broken Links
on:
push:
branches:
- main
jobs:
check-links:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Create markdown-link-check config
run: |
cat <<EOT > .markdown-link-check.json
{
"ignorePatterns": [
{
"pattern": "./Assets/*"
},
{
"pattern": "./assets/*"
}
]
}
EOT
- name: Install markdown-link-check
run: npm install -g markdown-link-check
- name: Check README links
id: check-links
run: |
markdown-link-check --config .markdown-link-check.json --verbose README.md > link-check-results.txt || true
echo "::group::Link Check Results"
cat link-check-results.txt
echo "::endgroup::"
- name: Annotate Results
run: |
# Extract broken links
broken_links=$(grep -B 1 "✖" link-check-results.txt || true)
if [ -n "$broken_links" ]; then
echo "::error title=Broken Links Found::The following links are broken:"
echo "$broken_links" | sed 's/%/%25/g; s/\n/%0A/g; s/\r/%0D/g'
# Print broken links in console for debugging
echo "Broken Links Details:"
echo "$broken_links"
exit 1
else
echo "::notice title=All Links Valid::All links in the README are valid."
fi