ci: match changed pages that live directly under docs/ #3
Workflow file for this run
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: Validate Documentation | |
| # main is covered by the strict build in deploy.yml; this catches problems | |
| # before they get there. | |
| on: | |
| pull_request: | |
| push: | |
| branches-ignore: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: validate-docs-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Python | |
| uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 | |
| with: | |
| python-version: '3.13' | |
| cache: pip | |
| cache-dependency-path: requirements.txt | |
| - name: Install dependencies | |
| run: pip install -r requirements.txt | |
| - name: Build | |
| run: mkdocs build --strict | |
| - name: Upload site for preview | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: site | |
| path: site/ | |
| retention-days: 7 | |
| lint: | |
| name: Markdown | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| # A code fence that is not indented by four spaces terminates the list it | |
| # follows, so the items after it restart at 1. Blocking, but only on the | |
| # pages this change touches - existing pages predate the rule and are | |
| # fixed as they are edited. | |
| - name: Check fences in changed pages | |
| env: | |
| BASE: ${{ github.event.pull_request.base.sha || 'origin/main' }} | |
| run: | | |
| # A 'docs/**/*.md' pathspec does not match docs/index.md under | |
| # git's default globbing, so filter the extension separately. | |
| changed=$(git diff --name-only --diff-filter=d "$BASE"...HEAD -- docs | grep '\.md$' || true) | |
| if [ -z "$changed" ]; then | |
| echo "No changed pages." | |
| exit 0 | |
| fi | |
| echo "$changed" | |
| # shellcheck disable=SC2086 | |
| if grep -PzoH '(?m)^\d+\.[^\n]*\n\n```' $changed | tr '\0' '\n'; then | |
| echo "::error::Indent these fences by four spaces so they stay inside the list item." | |
| exit 1 | |
| fi | |
| # Advisory: the house style predates this check and existing pages still | |
| # violate it. Fix them as they are touched, then drop continue-on-error. | |
| - name: markdownlint | |
| continue-on-error: true | |
| uses: DavidAnson/markdownlint-cli2-action@21c1be1b93ad9ed58fa840aacc3f279cde2a72ff # v24.2.0 | |
| with: | |
| globs: 'docs/**/*.md' |