name: docs

on:
  push:
    branches: [ master ]

env:
  CARGO_TERM_COLOR: always

jobs:
  docs:
    runs-on: ubuntu-latest
    permissions:
      id-token: "write"
      contents: "read"
      pages: "write"

    steps:
    - uses: actions/checkout@v4
    - uses: DeterminateSystems/nix-installer-action@main
    - uses: cachix/cachix-action@v14
      with:
        name: mnn-rs
        authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
    - uses: DeterminateSystems/flake-checker-action@main

    - name: Generate docs
      run: nix build .#checks.x86_64-linux.mnn-docs

    - name: Setup Pages
      uses: actions/configure-pages@v5

    - name: Upload artifact
      uses: actions/upload-pages-artifact@v3
      with:
        path: result/share/doc

    - name: Deploy to gh-pages
      id: deployment
      uses: actions/deploy-pages@v4

