name: Rust Documentation

on:
  push:
    branches:
      - main
      - jeremy/rust
    tags: '*'

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-20.04]

    runs-on: ${{ matrix.os }}

    steps:
    - name: Environment setup
      uses: actions/checkout@v2
    - name: Rust setup
      uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
    - name: Build documentation
      run: |
        cd rust
        cargo doc --all --no-deps
        cd ..
        touch ./target/doc/.nojekyll
        echo "<meta http-equiv=refresh content=0;url=libceed/index.html>" > ./target/doc/index.html
    - name: Deploy documentation
      uses: peaceiris/actions-gh-pages@v3
      with:
        external_repository: CEED/libCEED-rust-docs
        deploy_key: ${{ secrets.RUST_DOCS_KEY }}
        publish_dir: ./target/doc
