Merge branch 'dev' #67
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: 🌎 Pages Build with Trunk and Deploy | |
on: | |
push: | |
branches: | |
# Run when we push to any branch that starts with `cicd/` | |
- 'cicd/**' | |
# Run when we push to `main` b/c the publish on release create or publish doesn't work. | |
- 'main' | |
# Add the ability to run this workflow manually from the Actions tab. | |
workflow_dispatch: | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
jobs: | |
build-github-pages: | |
environment: | |
name: Build with Trunk and Deploy with GitHub's "static" Starter Workflow | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Include static images. | |
lfs: true | |
# Include the Juice theme. | |
submodules: true | |
### Install Trunk and build WASM first because we need it as part of Zola's static files. | |
# todo: Switch to better caching toolchain. | |
- uses: actions-rs/toolchain@v1 # get rust toolchain for wasm | |
with: | |
profile: minimal | |
toolchain: stable | |
target: wasm32-unknown-unknown | |
override: true | |
# todo: Switch to better caching Action. | |
- name: Rust Cache # cache the rust build artifacts | |
uses: Swatinem/rust-cache@v1 | |
- name: Download and Install Trunk Binary | |
run: wget -qO- https://github.com/thedodd/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-; | |
# Install Trunk in (app dir) `/home/runner/work/folsum/folsum/` because `trunk` doesn't have a path parameter. | |
working-directory: folsum | |
- name: Build WASM Distribution with Trunk | |
# "${GITHUB_REPOSITORY#*/}" evaluates into the name of the repository | |
# using --public-url something will allow trunk to modify all the href paths like from favicon.ico to repo_name/favicon.ico . | |
# this is necessary for github pages where the site is deployed to username.github.io/repo_name and all files must be requested | |
# relatively as eframe_template/favicon.ico. if we skip public-url option, the href paths will instead request username.github.io/favicon.ico which | |
# will obviously return error 404 not found. | |
# Create static WASM files in `folsum/folsum/dist/` use `--public-url` to note that `dist/` will contain all WASM files. | |
run: ./trunk build --release --public-url /dist/; | |
# Run build command in (app dir) `folsum/folsum/` because `trunk` doesn't have a path parameter. | |
working-directory: folsum | |
- name: Move Trunk's WASM Files | |
# Move these into Zola's static directory so Zola can build paths to the JS and WASM files when it builds the site. | |
run: cp -r folsum/dist xtask/website/static/dist | |
- name: ls static dist | |
run: ls xtask/website/static/dist | |
### Install Zola and build static site second. | |
- name: Download and Install Zola Binary | |
run: | | |
LATEST_ZOLA=$(curl -s https://api.github.com/repos/getzola/zola/releases/latest | jq -r '.tag_name') | |
wget -q https://github.com/getzola/zola/releases/download/${LATEST_ZOLA}/zola-${LATEST_ZOLA}-x86_64-unknown-linux-gnu.tar.gz | |
tar -xzf zola-${LATEST_ZOLA}-x86_64-unknown-linux-gnu.tar.gz | |
# Install Trunk in (app dir) `/home/runner/work/folsum/folsum/` because `zola` doesn't have a path parameter. | |
working-directory: xtask/website | |
- name: Build Static Site with Zola | |
# Build website and output static files in `folsum/xtask/website/public/`. | |
run: ./zola build; | |
working-directory: xtask/website | |
# Deploy static files with GitHub's "static" starter workflow. https://github.com/actions/starter-workflows/blob/main/pages/static.yml | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
# Upload contents of Zola's output directory. | |
path: 'xtask/website/public/' | |
# Upload contents of Trunk's output directory. | |
# path: 'folsum/dist/' | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |