name: Deploy

on:
  push:
    branches:
      - main
      # - server_support

  pull_request:
    branches:
      - main
      # - server_support

defaults:
  run:
    shell: bash

permissions:
  contents: write

jobs:
  deploy:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - uses: actions/checkout@v4
      - name: Install Rust
        run: |
          rustup set profile minimal
          rustup toolchain install stable
          rustup default stable
      - name: Setup mdBook
        uses: peaceiris/actions-mdbook@v2
        with:
          mdbook-version: "latest"
      - run: mdbook build
      # - name: Copy Assets
      #   run: |
      #     chmod +x ci/copy-assets.sh
      #     ci/copy-assets.sh ${{ matrix.os }}
      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        # or || github.ref == 'refs/heads/server_support'
        if: ${{ github.ref == 'refs/heads/main' }}
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./book