diff --git a/.github/workflows/docs-check-links.sh b/.github/workflows/docs-check-links.sh new file mode 100755 index 0000000000..888c114826 --- /dev/null +++ b/.github/workflows/docs-check-links.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -e + +# Check that documentation links work + +# The next line returns code 200 only if the page exists +link_code="$(curl -s -o /dev/null -w "%{http_code}" $URL)" + +# Find bad links +set +e +good_links="200" +if [[ "${link_code}" != good_links ]]; then + echo "One or more links in the documentation failed:" >&2 + echo $link_code >&2 + exit 1 +fi + +exit 0 diff --git a/.github/workflows/docs-check-links.yml b/.github/workflows/docs-check-links.yml new file mode 100644 index 0000000000..c6bf847280 --- /dev/null +++ b/.github/workflows/docs-check-links.yml @@ -0,0 +1,28 @@ +name: Check documentation links + +on: + push: + # Run when a change to these files is pushed to any branch. Without the "branches:" line, for some reason this will be run whenever a tag is pushed, even if the listed files aren't changed. + branches: ['*'] + paths: + - 'doc/**' + + pull_request: + # Run on pull requests that change the listed files + paths: + - 'doc/**' + + # Allows user to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + link-checker: + runs-on: ubuntu-latest + steps: + - name: Check documentation links + run: | + .github/workflows/docs-check-links.sh + env: + # Use GITHUB_TOKEN to avoid rate limiting when checking GitHub links + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +