|
1 | 1 | name: Github Pages |
2 | 2 |
|
| 3 | +# By default, runs if you push to main. keeps your deployed app in sync with main branch. |
3 | 4 | on: |
4 | 5 | push: |
5 | 6 | branches: |
6 | 7 | - main |
| 8 | +# to only run when you do a new github release, comment out above part and uncomment the below trigger. |
| 9 | +# on: |
| 10 | +# release: |
| 11 | +# types: |
| 12 | +# - published |
7 | 13 |
|
8 | 14 | permissions: |
9 | | - contents: write |
| 15 | + contents: write # for committing to gh-pages branch. |
10 | 16 |
|
11 | 17 | jobs: |
12 | 18 | build-github-pages: |
13 | 19 | runs-on: ubuntu-latest |
14 | 20 | steps: |
15 | | - - uses: actions/checkout@v4 |
16 | | - |
17 | | - # ✅ Properly set up Rust 1.88.0 and cargo 1.88.0 |
18 | | - - uses: actions/setup-rust@v1 |
19 | | - with: |
20 | | - rust-version: 1.88.0 |
21 | | - |
22 | | - - name: Add wasm target |
23 | | - run: rustup target add wasm32-unknown-unknown |
24 | | - |
25 | | - - name: Rust Cache |
| 21 | + - uses: actions/checkout@v4 # repo checkout |
| 22 | + - name: Setup toolchain for wasm |
| 23 | + run: | |
| 24 | + rustup update stable |
| 25 | + rustup default stable |
| 26 | + rustup set profile minimal |
| 27 | + rustup target add wasm32-unknown-unknown |
| 28 | + - name: Rust Cache # cache the rust build artefacts |
26 | 29 | uses: Swatinem/rust-cache@v2 |
27 | | - |
28 | 30 | - name: Download and install Trunk binary |
29 | 31 | run: wget -qO- https://github.com/thedodd/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf- |
30 | | - |
31 | | - - name: Build |
| 32 | + - name: Build # build |
| 33 | + # Environment $public_url resolves to the github project page. |
| 34 | + # If using a user/organization page, remove the `${{ github.event.repository.name }}` part. |
| 35 | + # using --public-url something will allow trunk to modify all the href paths like from favicon.ico to repo_name/favicon.ico . |
| 36 | + # this is necessary for github pages where the site is deployed to username.github.io/repo_name and all files must be requested |
| 37 | + # relatively as eframe_template/favicon.ico. if we skip public-url option, the href paths will instead request username.github.io/favicon.ico which |
| 38 | + # will obviously return error 404 not found. |
32 | 39 | run: ./trunk build --release --public-url $public_url |
33 | 40 | env: |
34 | 41 | public_url: "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}" |
35 | | - |
36 | 42 | - name: Deploy |
37 | 43 | uses: JamesIves/github-pages-deploy-action@v4 |
38 | 44 | with: |
39 | 45 | folder: dist |
| 46 | + # this option will not maintain any history of your previous pages deployment |
| 47 | + # set to false if you want all page build to be committed to your gh-pages branch history |
40 | 48 | single-commit: true |
0 commit comments