/ .github / workflows / docs.yml
docs.yml
 1  name: Deploy Docs
 2  
 3  on:
 4    push:
 5      branches: [main]
 6      paths:
 7        - 'docs/**'
 8        - 'mkdocs.yml'
 9        - 'overrides/**'
10        - '.github/workflows/docs.yml'
11        - 'crates/auths-cli/src/**'
12        - 'crates/xtask/src/**'
13    pull_request:
14      branches: [main]
15      paths:
16        - 'docs/**'
17        - 'mkdocs.yml'
18        - 'overrides/**'
19        - 'crates/auths-cli/src/**'
20        - 'crates/xtask/src/**'
21  
22  permissions:
23    contents: write
24  
25  jobs:
26    deploy:
27      name: Deploy docs
28      runs-on: ubuntu-latest
29      steps:
30        - uses: actions/checkout@v4
31          with:
32            fetch-depth: 0  # full history for git-revision-date
33  
34        - name: Install Rust toolchain
35          uses: dtolnay/rust-toolchain@stable
36  
37        - name: Cache Rust build
38          uses: actions/cache@v4
39          with:
40            path: |
41              ~/.cargo/registry
42              ~/.cargo/git
43              target
44            key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
45            restore-keys: ${{ runner.os }}-cargo-
46  
47        - name: Regenerate CLI docs
48          run: cargo run -p xtask -- gen-docs
49  
50        - uses: actions/setup-python@v5
51          with:
52            python-version: '3.12'
53  
54        - name: Install dependencies
55          run: pip install mkdocs-material
56  
57        - name: Build docs (PR check)
58          if: github.event_name == 'pull_request'
59          run: mkdocs build --strict
60  
61        - name: Deploy to GitHub Pages
62          if: github.event_name == 'push' && github.ref == 'refs/heads/main'
63          run: mkdocs gh-deploy --force