Build and Deploy Website #835
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: Build and Deploy Website | |
on: | |
merge_group: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
jobs: | |
prepare_last_release: | |
name: Prepare last release | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Set CARGO_TARGET_DIR | |
run: echo "CARGO_TARGET_DIR=$HOME/target" >> $GITHUB_ENV | |
- name: Install build tools | |
run: sudo apt-get update && sudo apt-get install build-essential libelf-dev zip libasound-dev -y | |
- name: Setup just | |
uses: extractions/setup-just@v2 | |
- name: Setup mdBook | |
uses: peaceiris/actions-mdbook@v2 | |
with: | |
mdbook-version: "0.4.13" | |
- name: Cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
~/target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Checkout latest release | |
run: cp justfile ../justfile && git switch --detach $(git describe --tags --abbrev=0) && mv ../justfile justfile | |
- name: Prepare web dependencies | |
run: just package-site-dependencies | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: site-deps | |
path: "target/site-deps.tar.gz" | |
build: | |
name: Build website | |
runs-on: ubuntu-24.04 | |
needs: prepare_last_release | |
steps: | |
- name: Set CARGO_TARGET_DIR | |
run: echo "CARGO_TARGET_DIR=$HOME/target" >> $GITHUB_ENV | |
- name: Install build tools | |
run: sudo apt-get update && sudo apt-get install build-essential libelf-dev zip -y | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download site dependencies | |
uses: actions/download-artifact@v4 | |
with: | |
name: site-deps | |
path: target/ | |
- name: Cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
website/agb/node_modules | |
website/agb/.next/cache | |
~/.cargo/registry | |
~/.cargo/git | |
~/target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}--npm--${{ hashFiles('**/package-lock.json') }} | |
- uses: extractions/setup-just@v2 | |
- name: Setup wasm | |
run: just setup-cargo-wasm | |
- name: Build website | |
run: just podman_command=docker build-site | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: "website/build" | |
deploy: | |
name: Deploy website | |
if: github.event_name == 'push' | |
# Add a dependency to the build job | |
needs: build | |
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
# Deploy to the github-pages environment | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
# Specify runner + deployment step | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |