Skip to content

Commit 30c3097

Browse files
committed
Create publish-web.yml
1 parent 02df9bb commit 30c3097

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

.github/workflows/publish-web.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build and Deploy to Github Pages
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
11+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
12+
concurrency:
13+
group: "pages"
14+
cancel-in-progress: false
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Set up cache
27+
uses: actions/cache@v4
28+
with:
29+
path: |
30+
~/.rustup
31+
~/.cargo/.crates.toml
32+
~/.cargo/.crates2.json
33+
~/.cargo/bin/
34+
~/.cargo/registry/index/
35+
~/.cargo/registry/cache/
36+
~/.cargo/git/db/
37+
target/
38+
key: ${{ runner.os }}-${{ github.workflow }}-rust-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/rust-toolchain.toml') }}
39+
40+
- name: Install WASM toolchain
41+
run: rustup target add wasm32-unknown-unknown
42+
43+
- name: Install trunk
44+
run: cargo install --locked trunk@0.21.14
45+
46+
- name: Build project
47+
working-directory: ./web
48+
run: trunk build --release --verbose
49+
50+
- name: Single page app
51+
run: cp ./web/dist/index.html ./web/dist/404.html
52+
53+
- name: Upload artifact
54+
uses: actions/upload-pages-artifact@v3
55+
with:
56+
path: "./web/dist"
57+
58+
deploy:
59+
needs: build
60+
runs-on: ubuntu-latest
61+
62+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
63+
permissions:
64+
pages: write # to deploy to Pages
65+
id-token: write # to verify the deployment originates from an appropriate source
66+
67+
# Deploy to the github-pages environment
68+
environment:
69+
name: github-pages
70+
url: ${{ steps.deployment.outputs.page_url }}
71+
72+
steps:
73+
- name: Deploy to GitHub Pages
74+
id: deployment
75+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)