Skip to content

Commit 92ffc1e

Browse files
authored
Merge pull request #389 from ChinYikMing/ci-deploy-wasm
CI: Deploy wasm
2 parents 35f641c + cb9cd91 commit 92ffc1e

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

.github/workflows/deploy-wasm.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Deploy wasm
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
types:
8+
- closed
9+
workflow_dispatch:
10+
branches:
11+
- master
12+
13+
jobs:
14+
wasm-deploy:
15+
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check out the repo
19+
uses: actions/checkout@v4
20+
- name: Verify if the JS or HTML file has been modified
21+
id: changed-files
22+
uses: tj-actions/changed-files@v40
23+
with:
24+
files: |
25+
assets/html/index.html
26+
assets/js/pre.js
27+
- name: install emcc
28+
if: ${{ steps.changed-files.outputs.any_changed == 'true' ||
29+
github.event_name == 'workflow_dispatch'}}
30+
run: |
31+
git clone https://github.com/emscripten-core/emsdk.git
32+
cd emsdk
33+
git pull
34+
git checkout 3.1.51
35+
./emsdk install latest
36+
./emsdk activate latest
37+
source ./emsdk_env.sh
38+
echo "$PATH" >> $GITHUB_PATH
39+
shell: bash
40+
- name: build with emcc and move application files to /tmp
41+
if: ${{ steps.changed-files.outputs.any_changed == 'true' ||
42+
github.event_name == 'workflow_dispatch'}}
43+
run: |
44+
make CC=emcc ENABLE_GDBSTUB=0 ENABLE_SDL=1
45+
mkdir /tmp/rv32emu-demo
46+
mv assets/html/index.html /tmp/rv32emu-demo
47+
mv assets/js/coi-serviceworker.min.js /tmp/rv32emu-demo
48+
mv build/rv32emu.js /tmp/rv32emu-demo
49+
mv build/rv32emu.wasm /tmp/rv32emu-demo
50+
mv build/rv32emu.worker.js /tmp/rv32emu-demo
51+
ls -al /tmp/rv32emu-demo
52+
- name: Check out the rv32emu-demo repo
53+
uses: actions/checkout@v4
54+
with:
55+
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
56+
repository: sysprog21/rv32emu-demo
57+
- name: Create local changes
58+
run: |
59+
mv /tmp/rv32emu-demo/index.html .
60+
mv /tmp/rv32emu-demo/coi-serviceworker.min.js .
61+
mv /tmp/rv32emu-demo/rv32emu.js .
62+
mv /tmp/rv32emu-demo/rv32emu.wasm .
63+
mv /tmp/rv32emu-demo/rv32emu.worker.js .
64+
- name: Commit files
65+
run: |
66+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
67+
git config --local user.name "github-actions[bot]"
68+
git add --all
69+
git commit -m "Add changes"
70+
- name: Push changes
71+
uses: ad-m/github-push-action@master
72+
with:
73+
repository: sysprog21/rv32emu-demo
74+
github_token: ${{ secrets.RV32EMU_DEMO_TOKEN }}
75+
branch: main

0 commit comments

Comments
 (0)