From 80050343948a15352f81c39458abd8f6148d2b07 Mon Sep 17 00:00:00 2001 From: nazeh Date: Sun, 8 Sep 2024 11:31:28 +0300 Subject: [PATCH] docs: add build cache --- .github/workflows/rust.yaml | 40 +++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index c6a2fe9..bde8d3e 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -74,20 +74,44 @@ jobs: - name: Run docs run: cargo doc --workspace --all-features --no-deps --document-private-items --verbose - - name: Install mdBook and mdBook-Mermaid + + + - name: Cache mdbook installation + uses: actions/cache@v2 + with: + path: ~/.cargo/bin/mdbook + key: ${{ runner.os }}-mdbook + + - name: Cache mdbook-mermaid installation + uses: actions/cache@v2 + with: + path: ~/.cargo/bin/mdbook + key: ${{ runner.os }}-mdbook-mermaid + + - name: Install mdBook if not installed already run: | - cargo install mdbook - cargo install mdbook-mermaid - mdbook-mermaid install ./docs/ + if [ ! -f ~/.cargo/bin/mdbook ]; then + cargo install mdbook + fi + + - name: Install mdBook-mermaid if not installed already + run: | + if [ ! -f ~/.cargo/bin/mdbook-mermaid ]; then + cargo install mdbook-mermaid + fi - name: Cache mdBook build - id: cache-mdbook + id: mdbook-build-cache uses: actions/cache@v3 with: - path: path/to/your/book/book-output - key: ${{ runner.os }}-mdbook-${{ hashFiles('path/to/your/book/**') }} + path: ./docs/book/ + key: ${{ runner.os }}-mdbook-${{ hashFiles('./docs/**') }} restore-keys: | ${{ runner.os }}-mdbook- - name: Build the book - run: mdbook build /docs/ + run: mdbook build ./docs/ + + - name: Build the book + if: steps.mdbook-build-cache.outputs.cache-hit != 'true' + run: mdbook build ./docs/