name: Document
on:
  push:
    branches:
      - master
jobs:
  all:
    runs-on: ubuntu-20.04
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
    - uses: hecrj/setup-rust-action@v1
      with:
        rust-version: nightly
    - uses: actions/checkout@v2
    - name: Generate documentation
      run: |
        RUSTDOCFLAGS="--cfg docsrs" \
          cargo doc --no-deps --all-features \
          -p iced_core \
          -p iced_style \
          -p iced_futures \
          -p iced_native \
          -p iced_lazy \
          -p iced_graphics \
          -p iced_wgpu \
          -p iced_glow \
          -p iced_winit \
          -p iced_glutin \
          -p iced
    - name: Write CNAME file
      run: echo 'docs.iced.rs' > ./target/doc/CNAME
    - name: Publish documentation
      uses: peaceiris/actions-gh-pages@v3
      with:
        deploy_key: ${{ secrets.DOCS_DEPLOY_KEY }}
        external_repository: iced-rs/docs
        publish_dir: ./target/doc
