name: Upload documentation

on:
  push:
    branches: [master]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Install Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: nightly-x86_64-unknown-linux-gnu
          profile: minimal
          override: true

      - name: Build Docs
        uses: actions-rs/cargo@v1
        with:
          command: doc
          args: --workspace --all-features --no-deps

      - name: Tweak HTML
        run: echo '<meta http-equiv="refresh" content="0;url=actix_server/index.html">' > target/doc/index.html

      - name: Deploy to GitHub Pages
        uses: JamesIves/github-pages-deploy-action@3.7.1
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BRANCH: gh-pages
          FOLDER: target/doc