peace 0.0.15

zero stress automation
Documentation
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - '**'

name: Book

jobs:
  publish_book:
    name: Peace Book
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable

      - name: 'Install `wasm-pack`'
        uses: jetli/wasm-pack-action@v0.4.0
        with:
          version: 'v0.13.0'

      - name: mdbook Cache
        id: mdbook_cache
        uses: actions/cache@v4
        with:
          path: ~/.cargo/bin/mdbook
          key: ${{ runner.os }}-mdbook

      - name: mdbook-graphviz Cache
        id: mdbook_graphviz_cache
        uses: actions/cache@v4
        with:
          path: ~/.cargo/bin/mdbook-graphviz
          key: ${{ runner.os }}-mdbook-graphviz

      - name: Setup Graphviz
        uses: ts-graphviz/setup-graphviz@v2

      - run: cargo install mdbook-graphviz
        if: steps.mdbook_graphviz_cache.outputs.cache-hit != 'true'

      # When updating this, also update ci.yml
      - name: 'Example: download (WASM)'
        # The following no longer works, because the AWS SDK uses tokio with UDP features enabled:
        # for example in $(ls examples)
        run: |
          for example in download
          do wasm-pack build \
            --target web \
            --out-dir "../../doc/src/examples/pkg" \
            --release \
            "examples/${example}" \
            --features 'error_reporting'
          done

      # use custom version of mdbook for now
      - name: Install `mdbook`
        run: cargo install mdbook --git https://github.com/azriel91/mdBook.git --branch improvement/code-blocks
        if: steps.mdbook_cache.outputs.cache-hit != 'true'

      - run: mdbook build doc

      # Note: `test` doesn't work with the examples' inlined HTML.
      # - run: mdbook test doc

      # We *do* want to include the built wasm files.
      - run: rm -f ./doc/book/examples/pkg/.gitignore

      - name: Publish to `gh-pages`
        if: ${{ github.ref == 'refs/heads/main' }}
        uses: peaceiris/actions-gh-pages@v4
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./doc/book
          force_orphan: true