diff --git a/.github/workflows/deploy wasm to gh-pages.yml b/.github/workflows/deploy wasm to gh-pages.yml new file mode 100644 index 0000000..242700d --- /dev/null +++ b/.github/workflows/deploy wasm to gh-pages.yml @@ -0,0 +1,34 @@ +on: push +name: Build and deploy web page with WASM version +jobs: + build: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' + steps: + - name: Checkout project + uses: actions/checkout@v3 + - name: Set up Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + target: wasm32-unknown-unknown + override: true + - name: Build and deploy WASM binary + run: | + cargo build --release --target wasm32-unknown-unknown + wasm-bindgen target\wasm32-unknown-unknown\release\rust-rl.wasm --out-dir wasm --no-modules --no-typescript + cp wasm\rust-rl_bg.wasm web\ + cp wasm\rust-rl.js web\ + - name: Publish static website + env: + GITHUB_TOKEN: ${{ github.token }} + run: | + cd web/ + git init --initial-branch=master + git config user.name "GitHub Actions" + git config user.email "github-actions-bot@users.noreply.github.com" + git add . + + git commit -m "Deploy ${GITHUB_REPOSITORY} to ${GITHUB_REPOSITORY}:gh-pages" + git push --force "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" master:gh-pages + echo "Deploy complete"