-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (94 loc) · 2.92 KB
/
deploy-preview.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# https://vercel.com/guides/how-can-i-use-github-actions-with-vercel
name: Deploy preview
on:
pull_request:
branches: [ "master" ]
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
CARGO_TERM_COLOR: always
GITHUB_SHA: ${{ github.sha }}
jobs:
fake-build-wasm:
if: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Generate fake ./www/public/out content
run: sh ./fake-build-wasm.sh
- name: Cache wasm-bindgen output
uses: actions/cache@v3
with:
path: www/public/out
key: wasm-${{ github.run_id }}
restore-keys: wasm-
build-wasm:
if: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown
override: true
- name: install wasm-bindgen-cli
run: |
cargo install wasm-bindgen-cli@0.2.86
- name: install wasm-opt
run: |
cargo install wasm-opt
- name: Build
run: make wasm-build-opt
- name: Cache wasm-bindgen output
uses: actions/cache@v3
with:
path: www/public/out
key: wasm-${{ github.run_id }}
restore-keys: wasm-
build-www:
env:
WEBSITE_BASE_PATH: https://bevy-rust-wasm-experiments.vercel.app
needs: build-wasm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Restore cache wasm-bindgen output
uses: actions/cache@v3
with:
path: www/public/out
key: wasm-${{ github.run_id }}
- name: Setup Node 🥣
uses: actions/setup-node@v3
with:
node-version: 18
- run: node -v
- run: npm -v
- name: Install www dependencies
run: npm install
working-directory: ./www
- name: Install Vercel CLI
run: npm install --global vercel@latest
working-directory: ./www
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
working-directory: ./www
- name: Build Project Artifacts
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
working-directory: ./www
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > /tmp/deployment-url.txt
working-directory: ./www
- name: Comment on PR
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
let fs = require('fs');
let deploymentUrl = fs.readFileSync('/tmp/deployment-url.txt');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `✅ Preview ${deploymentUrl}\n\nBuilt with commit ${process.env.GITHUB_SHA}`
});