1
1
name : Development
2
2
3
3
on :
4
- pull_request_target :
4
+ pull_request :
5
5
types : [opened, synchronize, reopened]
6
6
7
7
jobs :
33
33
with :
34
34
ref : " ${{ github.event.pull_request.merge_commit_sha }}"
35
35
36
+ - name : Set up Node.js 22
37
+ uses : actions/setup-node@v4
38
+ with :
39
+ node-version : ' 22'
40
+
36
41
- name : Install dependencies
37
42
run : npm ci
38
43
67
72
with :
68
73
ref : " ${{ github.event.pull_request.merge_commit_sha }}"
69
74
75
+ - name : Set up Node.js 22
76
+ uses : actions/setup-node@v4
77
+ with :
78
+ node-version : ' 22'
79
+
70
80
- name : Install dependencies
71
81
run : npm ci
72
82
91
101
- name : Run pre-commit checks
92
102
run : SKIP=ruff-format pre-commit run --all-files
93
103
94
- ui-precommit-check :
104
+ ui-precommit-checks :
95
105
permissions :
96
106
contents : " read"
97
107
runs-on : ubuntu-latest
@@ -101,6 +111,11 @@ jobs:
101
111
with :
102
112
ref : " ${{ github.event.pull_request.merge_commit_sha }}"
103
113
114
+ - name : Set up Node.js 22
115
+ uses : actions/setup-node@v4
116
+ with :
117
+ node-version : ' 22'
118
+
104
119
- name : Install dependencies
105
120
run : npm ci
106
121
@@ -133,6 +148,11 @@ jobs:
133
148
- name : Check out code
134
149
uses : actions/checkout@v3
135
150
151
+ - name : Set up Node.js 22
152
+ uses : actions/setup-node@v4
153
+ with :
154
+ node-version : ' 22'
155
+
136
156
- name : Install dependencies
137
157
run : npm ci
138
158
@@ -167,6 +187,11 @@ jobs:
167
187
with :
168
188
ref : " ${{ github.event.pull_request.merge_commit_sha }}"
169
189
190
+ - name : Set up Node.js 22
191
+ uses : actions/setup-node@v4
192
+ with :
193
+ node-version : ' 22'
194
+
170
195
- name : Install dependencies
171
196
run : npm ci
172
197
@@ -224,3 +249,102 @@ jobs:
224
249
They will be retained for **up to 30 days**.
225
250
`
226
251
})
252
+
253
+ ui-pr-preview :
254
+ needs : [ui-quality-checks, ui-precommit-checks, ui-unit-tests, ui-integration-tests]
255
+ permissions :
256
+ contents : write
257
+ pull-requests : write
258
+ issues : write
259
+ runs-on : ubuntu-latest
260
+ steps :
261
+ - name : Check out code
262
+ uses : actions/checkout@v3
263
+ with :
264
+ fetch-depth : 0
265
+
266
+ - name : Check if UI-related files changed
267
+ id : check-changes
268
+ run : |
269
+ BASE_BRANCH=${{ github.event.pull_request.base.ref }}
270
+ CHANGED_FILES=$(git diff --name-only origin/$BASE_BRANCH...HEAD)
271
+ SHOULD_BUILD=false
272
+
273
+ if echo "$CHANGED_FILES" | grep -q "^src/ui/"; then
274
+ echo "UI source files changed"
275
+ SHOULD_BUILD=true
276
+ fi
277
+
278
+ echo "should_build=$SHOULD_BUILD" >> $GITHUB_OUTPUT
279
+ echo "Should build: $SHOULD_BUILD"
280
+
281
+ - name : Install dependencies
282
+ if : steps.check-changes.outputs.should_build == 'true'
283
+ run : npm ci
284
+
285
+ - name : Build app to root
286
+ if : steps.check-changes.outputs.should_build == 'true'
287
+ id : build
288
+ run : |
289
+ # Export vars to ensure they are loaded before build
290
+ export $(grep -v '^#' .env.development | xargs)
291
+
292
+ PR_NUMBER=${{ github.event.pull_request.number }}
293
+ echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
294
+
295
+ # Set asset prefix and base path with PR number
296
+ ASSET_PREFIX=https://neuralmagic.github.io/guidellm/ui/pr/${PR_NUMBER}
297
+ USE_MOCK_DATA=true
298
+ BASE_PATH=/ui/pr/${PR_NUMBER}
299
+ GIT_SHA=${{ github.sha }}
300
+ export ASSET_PREFIX=${ASSET_PREFIX}
301
+ export BASE_PATH=${BASE_PATH}
302
+ export GIT_SHA=${GIT_SHA}
303
+ export USE_MOCK_DATA=${USE_MOCK_DATA}
304
+ npm run build
305
+
306
+ - name : Deploy to GitHub Pages
307
+ if : steps.check-changes.outputs.should_build == 'true'
308
+ uses : peaceiris/actions-gh-pages@v3
309
+ with :
310
+ github_token : ${{ secrets.GITHUB_TOKEN }}
311
+ publish_dir : ./src/ui/out
312
+ destination_dir : ui/pr/${{ steps.build.outputs.pr_number }}
313
+ keep_files : false
314
+ user_name : ${{ github.actor }}
315
+ user_email : ${{ github.actor }}@users.noreply.github.com
316
+ publish_branch : gh-pages
317
+ commit_message : ' build: Deploy preview build for PR #${{ github.event.pull_request.number }}'
318
+
319
+ - name : Set deployment url
320
+ if : steps.check-changes.outputs.should_build == 'true'
321
+ id : deploy
322
+ run : |
323
+ DEPLOY_URL=https://neuralmagic.github.io/guidellm/ui/pr/${{ steps.build.outputs.pr_number }}
324
+ echo "url=${DEPLOY_URL}" >> $GITHUB_OUTPUT
325
+
326
+ - name : Find PR comment
327
+ if : steps.check-changes.outputs.should_build == 'true'
328
+ uses : peter-evans/find-comment@v2
329
+ id : find-comment
330
+ with :
331
+ token : ${{ secrets.GITHUB_TOKEN }}
332
+ issue-number : ${{ github.event.pull_request.number }}
333
+ body-includes : ' <!-- pr-preview-comment -->'
334
+
335
+ - name : Post Deployment URL to PR
336
+ if : steps.check-changes.outputs.should_build == 'true'
337
+ uses : peter-evans/create-or-update-comment@v3
338
+ with :
339
+ token : ${{ secrets.GITHUB_TOKEN }}
340
+ comment-id : ${{ steps.find-comment.outputs.comment-id }}
341
+ issue-number : ${{ github.event.pull_request.number }}
342
+ edit-mode : replace
343
+ body : |
344
+ <!-- pr-preview-comment -->
345
+ 🎉 **Live Preview:** [Click here to view the live version](${{ steps.deploy.outputs.url }})
346
+ *Last updated: ${{ github.sha }}*
347
+
348
+ - name : Skip build notification
349
+ if : steps.check-changes.outputs.should_build == 'false'
350
+ run : echo "Skipping UI preview build - no relevant files changed"
0 commit comments