Skip to content

Commit 955f14e

Browse files
committed
Add GitHub Actions workflow to deploy WASM build to river-raid.github.io
1 parent 2676803 commit 955f14e

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/deploy-wasm.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Deploy WASM
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
env:
11+
TARGET_DIR: target
12+
steps:
13+
- uses: actions/checkout@v6
14+
15+
- uses: actions/setup-go@v6
16+
with:
17+
go-version-file: go.mod
18+
19+
- name: Build WASM
20+
run: GOOS=js GOARCH=wasm go build -o river-raid.wasm .
21+
22+
- name: Copy wasm_exec.js
23+
run: cp $(go env GOROOT)/lib/wasm/wasm_exec.js .
24+
25+
- name: Checkout target repo
26+
uses: actions/checkout@v6
27+
with:
28+
repository: river-raid/river-raid.github.io
29+
token: ${{ secrets.DEPLOY_TOKEN }}
30+
path: ${{ env.TARGET_DIR }}
31+
32+
- name: Copy artifacts
33+
run: |
34+
cp river-raid.wasm ${{ env.TARGET_DIR }}/
35+
cp wasm_exec.js ${{ env.TARGET_DIR }}/
36+
37+
- name: Commit and push
38+
working-directory: ${{ env.TARGET_DIR }}
39+
run: |
40+
git config user.name "github-actions[bot]"
41+
git config user.email "github-actions[bot]@users.noreply.github.com"
42+
git add river-raid.wasm wasm_exec.js
43+
git diff --cached --quiet || (git commit -m "Deploy WASM build from ${GITHUB_SHA::7}" && git push)

0 commit comments

Comments
 (0)