Skip to content

Commit

Permalink
add gh page
Browse files Browse the repository at this point in the history
  • Loading branch information
foxzool committed Nov 25, 2024
1 parent 70f05f3 commit 78e2298
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/deploy-page.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: deploy-github-page

on:
workflow_dispatch:

permissions:
contents: write

jobs:
build-web:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install Dependencies
run: sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev
# - name: Install trunk
# uses: jetli/trunk-action@v0.4.0
# with:
# version: 'latest'
- name: Install wasm-bindgen
run: |
cargo install wasm-bindgen-cli
- name: Add wasm target
run: |
rustup target add wasm32-unknown-unknown
- name: Build Example
run: |
cargo build --release --target wasm32-unknown-unknown
- name: Wasm bindgen
run: |
wasm-bindgen --no-typescript --target web --out-dir ./dist/ --out-name "jigsaw_puzzle" ./target/wasm32-unknown-unknown/release/jigsaw_puzzle.wasm
- name: optimize Wasm
uses: NiklasEi/wasm-opt-action@v2
with:
file: dist/*.wasm
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4.2.5
with:
branch: gh-pages
folder: dist
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ Cargo.lock

/tiles
/images
jigsaw_puzzle_generator/target
jigsaw_puzzle_generator/target
dist/*
!dist/index.html
23 changes: 23 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>Jigsaw Puzzle Game</title>
</head>
<body style="margin: 0;">
<script type="module">
import init from './jigsaw_puzzle'

init().catch((error) => {
if (!error.message.startsWith("Using exceptions for control flow, don't mind me. This isn't actually an error!")) {
throw error;
}
});
</script>
<canvas id="bevy">
Javascript and support for canvas is required
</canvas>
</body>

</html>

0 comments on commit 78e2298

Please sign in to comment.