Use specific upload #8
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: Github pages | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
CARGO_TERM_COLOR: always | |
RUSTFLAGS: --cfg=web_sys_unstable_apis # This flag is required because wgpu is still unstable on wasm. | |
jobs: | |
build: | |
# What's installed | |
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Add target | |
run: rustup target add wasm32-unknown-unknown | |
- name: Build WASM | |
run: cargo build --lib --target wasm32-unknown-unknown --no-default-features --verbose | |
- name: Install wasm-bindgen | |
run: cargo install wasm-bindgen-cli | |
- name: Run tests | |
run: cargo test --lib --target wasm32-unknown-unknown --no-default-features --verbose | |
- name: Generate JS | |
run: wasm-bindgen target/wasm32-unknown-unknown/debug/protos_rs.wasm --out-dir web/public/scripts --out-name protos_rs --no-modules --no-typescript | |
#- name: Optimize WASM | |
# run: wasm-opt target/wasm32-unknown-unknown/debug/protos_rs.wasm -O2 --fast-math -o target/wasm32-unknown-unknown/debug/protos_rs.wasm | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./web/public/ | |
deploy: | |
# Add a dependency to the build job | |
needs: build | |
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
# Deploy to the github-pages environment | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
# Specify runner + deployment step | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action |