Continuous deployment (WASM Build) #55
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: Continuous deployment (WASM Build) | |
on: | |
workflow_run: | |
branches: [ main ] | |
workflows: [ Continuous integration ] | |
types: [ completed ] | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup-rust | |
with: | |
target: wasm32-unknown-unknown | |
- name: Install wasm-pack 🔧 | |
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
- name: Build WebAssembly 🏗 | |
run: | | |
sed -i "s/#wasm# //" Cargo.toml | |
wasm-pack build --release --target web | |
- name: Copy index.html to pkg directory | |
run: cp index.html ./pkg | |
- name: Upload wasm dist artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: wasm-dist | |
path: ./pkg | |
- name: Clean cache # Otherwise the cache is much too big. | |
run: | | |
du -hs target | |
rm -rf target/*/incremental | |
rm -rf target/*/*/*slint* | |
du -hs target | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository 🛎️ | |
uses: actions/checkout@v2 | |
- name: Download wasm dist artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: wasm-dist | |
path: ./pkg | |
# The wasm build ignores all the files in the pkg dir, but they are needed for the deployment. | |
- name: Remove .gitignore from pkg directory | |
run: rm -f ./pkg/.gitignore | |
- name: Deploy to GitHub Pages 🚀 | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./pkg/ | |
keep_files: true |