# ============================================================================= # build.yml —— 學生 push 後,Gitea Actions 自動把 main.cpp 編成 WASM 網頁 # 並發佈到公開的 builds 區。學生通常不必改這個檔。 # ============================================================================= name: build-wasm on: [push] jobs: build: runs-on: gridpp # 對應 runner 的 label(act_runner-config.yaml) container: image: gridpp-builder:latest # 內含 emcc + raylib-web + Grid++ 引擎 # 安全:限制記憶體/CPU/行程數,搭配 timeout 防無窮迴圈或挖礦。 # 外連已由 runner 把 job 容器掛在 internal 網擋掉(連得到 gitea、連不到外網)。 # 掛 gridpp_builds 是為了最後一步把產物寫進 builds 區。 options: --memory=512m --cpus=1 --pids-limit=256 -v gridpp_builds:/srv/builds timeout-minutes: 2 # 防無窮迴圈/挖礦 steps: - name: 取得程式碼 uses: actions/checkout@v4 - name: 產生素材 assets.db run: python3 "$GRIDPP/create_assets.py" - name: 編成 WASM 網頁 run: | mkdir -p site emcc main.cpp -std=c++17 \ -I"$GRIDPP/include" -I"$RAYLIB_WEB/include" -L"$RAYLIB_WEB/lib" -lraylib \ -s USE_GLFW=3 -s ASYNCIFY -s ALLOW_MEMORY_GROWTH=1 \ --preload-file assets.db@assets.db \ --preload-file map.txt@map.txt \ --shell-file "$GRIDPP/shell.html" \ -o site/index.html - name: 發佈到 builds 區 run: | SHORT=$(echo "$GITHUB_SHA" | cut -c1-8) # commit 前 8 碼 DEST="/srv/builds/${GITHUB_ACTOR}/${SHORT}" mkdir -p "$DEST" cp site/index.html site/index.js site/index.wasm site/index.data "$DEST/" echo "✅ 公開連結:http://<本機IP>:8080/${GITHUB_ACTOR}/${SHORT}/"