build: Cache builds #243
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
component: clippy | |
- name: Cache Cargo registry and build | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
- name: Install specific version of mdbook and mdbook-hints | |
run: | | |
cargo install [email protected] | |
cargo install [email protected] | |
- name: Build the book | |
run: mdbook build | |
- name: Deploy GitHub Pages | |
run: | | |
git worktree add gh-pages | |
git config user.name "Deploy from CI" | |
git config user.email "" | |
cd gh-pages | |
git update-ref -d refs/heads/gh-pages | |
rm -rf * | |
mv ../book/* . | |
git add . | |
git commit -m "Deploy $GITHUB_SHA to gh-pages" | |
git push --force --set-upstream origin gh-pages |