Skip to content

Commit f4bda56

Browse files
committed
fix: Use cache for WebAssembly files when relevant files haven't changed
1 parent 8fad306 commit f4bda56

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.github/workflows/deploy.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ jobs:
5454
uses: actions/cache@v3
5555
with:
5656
path: hugo-site/static/wasm
57-
key: ${{ runner.os }}-wasm-${{ github.sha }}
57+
key: ${{ runner.os }}-wasm-${{ hashFiles('rust/gkwasm/**', 'rust/gklib/**') }}
5858

59-
# Build WebAssembly
59+
# Build WebAssembly if cache miss or files changed
6060
- name: Build WebAssembly
61+
if: steps.cache-wasm.outputs.cache-hit != 'true'
6162
run: cargo make build-wasm-release
6263

6364
# Build the site using cargo-make

Makefile.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,17 @@ dependencies = [
2525
[tasks.build-site]
2626
description = "Build WebAssembly and Hugo site for deployment"
2727
script = """
28-
echo "Building WebAssembly files..."
29-
cargo make build-wasm-release
28+
if [ -n "$GITHUB_ACTIONS" ]; then
29+
if [ -d "hugo-site/static/wasm" ] && [ -n "$(ls -A hugo-site/static/wasm)" ]; then
30+
echo "Using cached WebAssembly files"
31+
else
32+
echo "WebAssembly files not found in cache, rebuilding..."
33+
cargo make build-wasm-release
34+
fi
35+
else
36+
echo "Building WebAssembly files..."
37+
cargo make build-wasm-release
38+
fi
3039
cd hugo-site
3140
hugo --minify
3241
echo "Contents of public/wasm after running hugo:"

0 commit comments

Comments
 (0)