name: rustdoc
on:
  push:
    branches:
      - "master"

  workflow_dispatch:

env:
  CARGO_INCREMENTAL: 0
  CARGO_NET_RETRY: 10
  RUSTUP_MAX_RETRIES: 10

jobs:
  rustdoc:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Setup Rust toolchain
        uses: dsherret/rust-toolchain-file@v1

      - name: Build Documentation
        env:
          RUSTDOCFLAGS: "--enable-index-page -Zunstable-options"
        run: cargo doc --all --no-deps

      - name: Deploy Docs
        uses: peaceiris/actions-gh-pages@v3.9.3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_branch: gh-pages
          publish_dir: ./target/doc
          force_orphan: true
          cname: air.fluence.dev
