name: Deploy Docs to GitHub Pages

on:
  push:
    branches:
      - main  # Adjust this branch name if needed

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Set up Rust
        uses: actions/setup-rust@v1

      - name: Build Docs
        run: |
          cargo doc --no-deps
          rm -rf ./docs
          echo "<meta http-equiv=\"refresh\" content=\"0; url=csflow/index.html\">" > target/doc/index.html
          cp -r target/doc ./docs

      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./docs
