Skip to content

Commit 0ef02b6

Browse files
committed
Add GitHub Actions workflow for deploying to GitHub Pages
* **Build job** - Check out the repository - Set up Rust toolchain - Build the project for the `wasm32-unknown-unknown` target - Upload build artifacts * **Deploy job** - Depend on the `build` job - Check out the repository - Download build artifacts - Deploy to GitHub Pages using `peaceiris/actions-gh-pages@v3`
1 parent f18b20e commit 0ef02b6

File tree

1 file changed

+33
-37
lines changed

1 file changed

+33
-37
lines changed

.github/workflows/deploy-gh-pages.yml

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,49 @@
1-
# Simple workflow for deploying static content to GitHub Pages
2-
name: Deploy static content to Pages
1+
name: Deploy to GitHub Pages
32

43
on:
5-
# Runs on main when a release is published
6-
release:
7-
types: [published]
8-
branches: ["main"]
94
push:
10-
branches: ["main"]
11-
12-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13-
permissions:
14-
contents: read
15-
pages: write
16-
id-token: write
17-
18-
concurrency:
19-
group: "pages"
20-
cancel-in-progress: false
5+
branches:
6+
- main
217

228
jobs:
23-
# Single deploy job since we're just deploying
24-
deploy:
25-
environment:
26-
name: github-pages
27-
url: ${{ steps.deployment.outputs.page_url }}
9+
build:
2810
runs-on: ubuntu-latest
11+
2912
steps:
3013
- name: Checkout repository
31-
uses: actions/checkout@v4
14+
uses: actions/checkout@v2
15+
3216
- name: Set up Rust
3317
uses: actions-rs/toolchain@v1
3418
with:
3519
toolchain: stable
20+
override: true
21+
3622
- name: Build the project
3723
run: cargo build --release --target wasm32-unknown-unknown
38-
- name: Install wasm-bindgen-cli
39-
run: cargo install wasm-bindgen-cli
40-
- name: Generate wasm-bindgen output
41-
run: wasm-bindgen target/wasm32-unknown-unknown/release/random_shader_window.wasm --out-dir ./out --web
42-
- name: Copy index.html to deploy directory
43-
run: cp index.html ./out
44-
- name: Setup Pages
45-
uses: actions/configure-pages@v4
46-
- name: Upload artifact
47-
uses: actions/upload-pages-artifact@v3
24+
25+
- name: Upload artifacts
26+
uses: actions/upload-artifact@v2
4827
with:
49-
# Upload entire repository
50-
path: ./out
28+
name: wasm-build
29+
path: pkg
30+
31+
deploy:
32+
runs-on: ubuntu-latest
33+
needs: build
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v2
38+
39+
- name: Download artifacts
40+
uses: actions/download-artifact@v2
41+
with:
42+
name: wasm-build
43+
path: pkg
44+
5145
- name: Deploy to GitHub Pages
52-
id: deployment
53-
uses: actions/deploy-pages@v4
46+
uses: peaceiris/actions-gh-pages@v3
47+
with:
48+
github_token: ${{ secrets.GITHUB_TOKEN }}
49+
publish_dir: ./pkg

0 commit comments

Comments
 (0)