Update broken-links.yml #59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: Install markdown-link-check | |
| run: npm install -g markdown-link-check | |
| - name: Create Ignore Config | |
| run: | | |
| echo '{ | |
| "ignorePatterns": [ | |
| { | |
| "pattern": "^\\.\\/Assets\\/" | |
| } | |
| ] | |
| }' > markdown-link-check-config.json | |
| - name: Check README links | |
| id: check-links | |
| run: | | |
| markdown-link-check --verbose --config markdown-link-check-config.json 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 excluding ./Assets | |
| broken_links=$(grep -B 1 "✖" link-check-results.txt | grep -v "^\\.\\/Assets" || 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 |