|
| 1 | +name: Docs link check |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + lychee: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Check out repository |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + # Cache lychee results (e.g. to avoid hitting rate limits) |
| 20 | + # https://lychee.cli.rs/github_action_recipes/caching/ |
| 21 | + - name: Restore lychee cache |
| 22 | + uses: actions/cache@v4 |
| 23 | + with: |
| 24 | + path: .lycheecache |
| 25 | + key: cache-lychee-${{ github.sha }} |
| 26 | + restore-keys: cache-lychee- |
| 27 | + |
| 28 | + # https://github.com/lycheeverse/lychee/issues/1487 |
| 29 | + - name: Install CA Certificates for lychee |
| 30 | + run: | |
| 31 | + sudo apt-get install ca-certificates |
| 32 | +
|
| 33 | + - name: Install lychee |
| 34 | + run: | |
| 35 | + set -euo pipefail |
| 36 | + mkdir -p "$HOME/.local/bin" |
| 37 | + cd "$RUNNER_TEMP" |
| 38 | + # TODO: Lychee v0.19.1 doesn't support regex in --exclude-path, so use nightly |
| 39 | + # release until there is a released version containing regex support. |
| 40 | + curl -sSL -o lychee.tar.gz \ |
| 41 | + https://github.com/lycheeverse/lychee/releases/download/nightly/lychee-x86_64-unknown-linux-gnu.tar.gz |
| 42 | + tar -xzf lychee.tar.gz |
| 43 | + BIN_PATH=$(find . -maxdepth 2 -type f -name lychee | head -n1) |
| 44 | + install -m 0755 "$BIN_PATH" "$HOME/.local/bin/lychee" |
| 45 | + echo "$HOME/.local/bin" >> "$GITHUB_PATH" |
| 46 | + lychee --version |
| 47 | +
|
| 48 | + - name: Check documentation links with lychee |
| 49 | + env: |
| 50 | + # Set GITHUB_TOKEN to avoid github rate limits on URL checks |
| 51 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + run: | |
| 53 | + set -euo pipefail |
| 54 | + # Run lychee against all files in repo |
| 55 | + lychee \ |
| 56 | + --cache \ |
| 57 | + --no-progress \ |
| 58 | + --exclude-path "ATTRIBUTIONS.*" \ |
| 59 | + --accept "200..=299, 403, 429" \ |
| 60 | + --exclude-all-private --exclude 0.0.0.0 \ |
| 61 | + . |
0 commit comments