Skip to content

Create deploy.yml

Create deploy.yml #1

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: Deploy to GitHub Pages
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# set permissions of GITHUB_TOKEN to allow pages deployment
permissions:
contents: read
pages: write
id-token: write
# allow only one concurrent deployment, with "mailbox" queue
concurrency:
group: "pages"
cancel-in-progress: false
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: checkout
uses: actions/checkout@v4
# Cache cargo and target directories
- name: cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# install the rust toolchain targeting wasm32-unknown-unknown
- name: install-rust-toolchain
uses: actions-rs/[email protected]
with:
toolchain: stable
target: wasm32-unknown-unknown
# install wasm-pack tool
- name: install-wasm-pack
uses: jetli/[email protected]
# run wasm-pack to generate ./pkg/ with all the js and wasm
- name: run-wasm-pack-build
run: wasm-pack build --target web
# package all the files to one artifact directory
- name: create-artifact
run: |
mkdir out
cp ./index.html ./out/index.html
cp -r ./pkg/ ./out/pkg/
# upload the artifact
- name: Upload artifact
id: deployment
uses: actions/upload-pages-artifact@v3
with:
path: ./out
# deploy job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# needs build to be done first
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub pages
id: deployment
uses: actions/deploy-pages@v4