-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (121 loc) · 4.46 KB
/
ci.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: ci
on:
push:
branches: ["main", "release"]
paths:
- ".github/workflows/ci.yml"
- "app/**"
- "crates/**"
- "Cargo.toml"
- "Cargo.lock"
- "pnpm-lock.yaml"
- "package.json"
pull_request:
branches: ["main"]
types:
- opened
- synchronize
paths:
- ".github/workflows/ci.yml"
- "app/**"
- "crates/**"
- "Cargo.toml"
- "Cargo.lock"
- "pnpm-lock.yaml"
- "package.json"
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
pull-requests: write
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
steps:
- name: Comment deploy start
if: ${{ !startsWith(env.BRANCH_NAME, 'renovate/') && github.event_name == 'pull_request' }}
uses: mshick/add-pr-comment@v2
with:
message-id: cloudflare-deploy
message: |
### <span aria-hidden="true">🚧</span> Deploy Preview building...
| Name | Link |
|---------------------------------|------------------------|
|Latest commit | ${{ github.event.pull_request.head.sha }} |
|Latest deploy log | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
---
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Normalize branch name
run: echo "NORMALIZED_BRANCH_NAME=$(echo $BRANCH_NAME | tr -cs '[:alnum:]' '-' | sed 's/^-//;s/-$//' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Setup rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.81.0"
targets: "wasm32-unknown-unknown,x86_64-unknown-linux-gnu"
components: "clippy"
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-node@v4
name: Setup Node.js
with:
node-version: "20"
- uses: pnpm/action-setup@v3
name: Install pnpm
with:
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.PNPM_STORE_PATH }}
key: pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
pnpm-store-
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Run tests
run: cargo test --workspace --exclude gb_wasm --target x86_64-unknown-linux-gnu
- name: Lint
run: cargo clippy --target wasm32-unknown-unknown
- name: Build WASM
working-directory: ./crates/gb_wasm
run: "./x.mjs build"
- name: Install dependencies for web app
run: pnpm install --frozen-lockfile
- name: Build web app
working-directory: ./app/gameboy
run: pnpm run build
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
if: ${{ !startsWith(env.BRANCH_NAME, 'renovate/') }}
id: cloudflare-publish
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: gbplay
directory: dist
branch: ${{ env.NORMALIZED_BRANCH_NAME }}
workingDirectory: app/gameboy
wranglerVersion: "3"
- name: Comment deploy URL
uses: mshick/add-pr-comment@v2
if: ${{ !startsWith(env.BRANCH_NAME, 'renovate/') && github.event_name == 'pull_request' }}
with:
message-id: cloudflare-deploy
message: |
### <span aria-hidden="true">✅</span> Deploy Preview ready!
| Name | Link |
|---------------------------------|------------------------|
|Latest commit | ${{ github.event.pull_request.head.sha }} |
|Latest deploy log | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
|Preview URL | [${{ steps.cloudflare-publish.outputs.url }}](${{ steps.cloudflare-publish.outputs.url }}) |
|Branch Preview URL | [${{ env.NORMALIZED_BRANCH_NAME }}.gbplay.pages.dev](https://${{ env.NORMALIZED_BRANCH_NAME }}.gbplay.pages.dev) |
|Environment | ${{ steps.cloudflare-publish.outputs.environment }} |
---