This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: WASM Build and Deploy | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: true | |
jobs: | |
build-and-deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Install wasm-pack | |
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
- name: Build WASM | |
run: | | |
wasm-pack build wasm --target web | |
# Ensure build succeeded | |
if [ ! -d "wasm/pkg" ]; then | |
echo "WASM build failed - pkg directory not found" | |
exit 1 | |
fi | |
- name: Prepare deployment | |
run: | | |
# Create clean docs directory | |
rm -rf docs | |
mkdir -p docs/pkg | |
# Copy WASM build | |
cp -r wasm/pkg/* docs/pkg/ | |
# Verify files exist | |
if [ ! -f "docs/pkg/dollcode_wasm.js" ]; then | |
echo "Required WASM files missing" | |
exit 1 | |
fi | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: docs | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 |