Initial book content plus CI/CD via github pages #2
Workflow file for this run
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: Book | |
on: [push, pull_request] | |
jobs: | |
book: | |
name: Build and deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository and submodules | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
- name: Cache build artifacts | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo- | |
${{ runner.os }}- | |
# Remove book directory cache before publishing. | |
- name: Clean book build directory before publishing | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: cargo clean | |
- name: Install mdbook | |
uses: peaceiris/actions-mdbook@v1 | |
with: | |
mdbook-version: '0.4.10' | |
- name: Install mdbook-linkcheck | |
run: | | |
version="v0.7.4" | |
file="mdbook-linkcheck" | |
zip_file="mdbook-linkcheck.${version}.x86_64-unknown-linux-gnu.zip" | |
curl -sSL https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases/download/${version}/${zip_file} --output ${zip_file} | |
unzip -d bin ${zip_file} ${file} | |
chmod +x bin/${file} | |
rm ${zip_file} | |
echo "$(pwd)/bin" >> ${GITHUB_PATH} | |
- name: Report versions | |
run: | | |
rustc --version --verbose | |
mdbook --version | |
mdbook-linkcheck --version | |
- name: Build book | |
run: mdbook build | |
- name: Run spell check | |
uses: streetsidesoftware/cspell-action@v2 | |
with: | |
config: './cspell.json' | |
files: './**' | |
incremental_files_only: false | |
# Enforce strict spell check except on push to main branch. | |
strict: ${{ !(github.event_name == 'push' && github.ref == 'refs/heads/main') }} | |
# Move build artifacts to publish directory on push to main branch. | |
- name: Move build artifacts | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: | | |
rm -rf ./github_pages/book | |
mv ./book/html/ ./github_pages/book/ | |
# Deploy on push to main branch. | |
- name: Deploy | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
commit_message: ${{ github.event.head_commit.message }} | |
publish_branch: github_pages | |
publish_dir: ./github_pages | |