Skip to content

Check Broken Links

Check Broken Links #3

Workflow file for this run

name: Check Broken Links
on:
workflow_dispatch:
push:
branches: [ main ] # Runs on push to main branch
schedule:
- cron: "0 12 * * 1" # Runs every Monday at 12:00 UTC
jobs:
check-links:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
sparse-checkout: .linkinatorrc.json
sparse-checkout-cone-mode: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
- name: Wait for GitHub Pages deployment
run: sleep 60s # Delay to allow deployment to complete
- name: Get short SHA
run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Check links on the live site to the action output
run: |
echo "Commit SHA: $SHORT_SHA"
npx linkinator https://hyperledger-identus.github.io/docs/ --config .linkinatorrc.json --format text || true
echo "LINKINATOR_EXIT_CODE=$?" >> $GITHUB_ENV
- name: Check links on the live site and safe to a file
if: env.LINKINATOR_EXIT_CODE != 0
run: |
npx linkinator https://hyperledger-identus.github.io/docs/ --config .linkinatorrc.json > link-check-results.txt || true
- name: Upload Linkinator output
uses: actions/upload-artifact@v4
with:
name: linkinator-results-${{ env.SHORT_SHA }}
path: link-check-results.txt
- name: Faile the build if there are broken links
if: env.LINKINATOR_EXIT_CODE != 0
run: |
echo "Broken links detected. Check the artifact for details."
exit 1