name: Docs
on:
push:
branches: [master]
paths:
- "docs/**"
- ".github/workflows/docs.yml"
workflow_call:
concurrency:
group: docs-deploy
cancel-in-progress: true
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
with:
key: docs-build
- name: Install wasm-bindgen-cli
run: |
VERSION=$(grep -A1 'name = "wasm-bindgen"' Cargo.lock \
| grep 'version' | head -1 \
| sed 's/.*version = "\(.*\)".*/\1/')
echo "Installing wasm-bindgen-cli $VERSION"
cargo install wasm-bindgen-cli --version "$VERSION" --locked
- name: Install trunk
run: |
curl -L --proto '=https' --tlsv1.2 -sSf \
"https://github.com/trunk-rs/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz" \
| tar xvzf - trunk
sudo mv trunk /usr/local/bin/trunk
- name: Build docs
working-directory: docs
run: |
# Derive public-url from the actual repo name so it always matches
# the GitHub Pages URL regardless of hyphens/case in the repo name.
REPO_NAME="${GITHUB_REPOSITORY##*/}"
echo "Building with --public-url /$REPO_NAME/"
trunk build --release --public-url "/$REPO_NAME/"
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/dist
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
permissions:
pages: write
id-token: write
steps:
- name: Deploy to GitHub Pages
id: deploy
uses: actions/deploy-pages@v4