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 :
12
12
python : ["3.9", "3.13"]
13
13
steps :
14
14
- uses : actions/checkout@v4
15
- with :
16
- ref : " ${{ github.event.pull_request.merge_commit_sha }}"
17
15
- name : Set up Python
18
16
uses : actions/setup-python@v5
19
17
with :
29
27
runs-on : ubuntu-latest
30
28
steps :
31
29
- name : Check out code
32
- uses : actions/checkout@v3
30
+ uses : actions/checkout@v4
31
+
32
+ - name : Set up Node.js 22
33
+ uses : actions/setup-node@v4
33
34
with :
34
- ref : " ${{ github.event.pull_request.merge_commit_sha }} "
35
+ node-version : ' 22 '
35
36
36
37
- name : Install dependencies
37
38
run : npm ci
46
47
python : ["3.9", "3.13"]
47
48
steps :
48
49
- uses : actions/checkout@v4
49
- with :
50
- ref : " ${{ github.event.pull_request.merge_commit_sha }}"
51
50
- name : Set up Python
52
51
uses : actions/setup-python@v5
53
52
with :
63
62
runs-on : ubuntu-latest
64
63
steps :
65
64
- name : Check out code
66
- uses : actions/checkout@v3
65
+ uses : actions/checkout@v4
66
+
67
+ - name : Set up Node.js 22
68
+ uses : actions/setup-node@v4
67
69
with :
68
- ref : " ${{ github.event.pull_request.merge_commit_sha }} "
70
+ node-version : ' 22 '
69
71
70
72
- name : Install dependencies
71
73
run : npm ci
80
82
python : ["3.9"]
81
83
steps :
82
84
- uses : actions/checkout@v4
83
- with :
84
- ref : " ${{ github.event.pull_request.merge_commit_sha }}"
85
85
- name : Set up Python
86
86
uses : actions/setup-python@v5
87
87
with :
@@ -91,15 +91,18 @@ jobs:
91
91
- name : Run pre-commit checks
92
92
run : SKIP=ruff-format pre-commit run --all-files
93
93
94
- ui-precommit-check :
94
+ ui-precommit-checks :
95
95
permissions :
96
96
contents : " read"
97
97
runs-on : ubuntu-latest
98
98
steps :
99
99
- name : Check out code
100
- uses : actions/checkout@v3
100
+ uses : actions/checkout@v4
101
+
102
+ - name : Set up Node.js 22
103
+ uses : actions/setup-node@v4
101
104
with :
102
- ref : " ${{ github.event.pull_request.merge_commit_sha }} "
105
+ node-version : ' 22 '
103
106
104
107
- name : Install dependencies
105
108
run : npm ci
@@ -114,8 +117,6 @@ jobs:
114
117
python : ["3.9", "3.13"]
115
118
steps :
116
119
- uses : actions/checkout@v4
117
- with :
118
- ref : " ${{ github.event.pull_request.merge_commit_sha }}"
119
120
- name : Set up Python
120
121
uses : actions/setup-python@v5
121
122
with :
@@ -131,7 +132,12 @@ jobs:
131
132
runs-on : ubuntu-latest
132
133
steps :
133
134
- name : Check out code
134
- uses : actions/checkout@v3
135
+ uses : actions/checkout@v4
136
+
137
+ - name : Set up Node.js 22
138
+ uses : actions/setup-node@v4
139
+ with :
140
+ node-version : ' 22'
135
141
136
142
- name : Install dependencies
137
143
run : npm ci
@@ -146,8 +152,6 @@ jobs:
146
152
python : ["3.9", "3.13"]
147
153
steps :
148
154
- uses : actions/checkout@v4
149
- with :
150
- ref : " ${{ github.event.pull_request.merge_commit_sha }}"
151
155
- name : Set up Python
152
156
uses : actions/setup-python@v5
153
157
with :
@@ -163,9 +167,12 @@ jobs:
163
167
runs-on : ubuntu-latest
164
168
steps :
165
169
- name : Check out code
166
- uses : actions/checkout@v3
170
+ uses : actions/checkout@v4
171
+
172
+ - name : Set up Node.js 22
173
+ uses : actions/setup-node@v4
167
174
with :
168
- ref : " ${{ github.event.pull_request.merge_commit_sha }} "
175
+ node-version : ' 22 '
169
176
170
177
- name : Install dependencies
171
178
run : npm ci
@@ -174,6 +181,8 @@ jobs:
174
181
run : npm run test:integration
175
182
176
183
build :
184
+ # Only build if the PR branch is local
185
+ if : github.event.pull_request.head.repo.full_name == github.repository
177
186
runs-on : ubuntu-latest
178
187
strategy :
179
188
matrix :
@@ -183,7 +192,6 @@ jobs:
183
192
uses : actions/checkout@v4
184
193
with :
185
194
fetch-depth : 0
186
- ref : " ${{ github.event.pull_request.merge_commit_sha }}"
187
195
- name : Set up Python
188
196
uses : actions/setup-python@v5
189
197
with :
@@ -224,3 +232,129 @@ jobs:
224
232
They will be retained for **up to 30 days**.
225
233
`
226
234
})
235
+
236
+ ui-pr-preview :
237
+ needs : [ui-quality-checks, ui-precommit-checks, ui-unit-tests, ui-integration-tests]
238
+ permissions :
239
+ contents : write
240
+ pull-requests : write
241
+ issues : write
242
+ runs-on : ubuntu-latest
243
+ steps :
244
+ - name : Check out code
245
+ uses : actions/checkout@v3
246
+ with :
247
+ fetch-depth : 0
248
+
249
+ - name : Check if UI-related files changed
250
+ id : check-changes
251
+ run : |
252
+ BASE_BRANCH=${{ github.event.pull_request.base.ref }}
253
+ CHANGED_FILES=$(git diff --name-only origin/$BASE_BRANCH...HEAD)
254
+ SHOULD_BUILD=false
255
+
256
+ if echo "$CHANGED_FILES" | grep -q "^src/ui/"; then
257
+ echo "UI source files changed"
258
+ SHOULD_BUILD=true
259
+ fi
260
+
261
+ echo "should_build=$SHOULD_BUILD" >> $GITHUB_OUTPUT
262
+ echo "Should build: $SHOULD_BUILD"
263
+
264
+ - name : Install dependencies
265
+ if : steps.check-changes.outputs.should_build == 'true'
266
+ run : npm ci
267
+
268
+ - name : Build app to root
269
+ if : steps.check-changes.outputs.should_build == 'true'
270
+ id : build
271
+ run : |
272
+ # Export vars to ensure they are loaded before build
273
+ export $(grep -v '^#' .env.development | xargs)
274
+
275
+ PR_NUMBER=${{ github.event.pull_request.number }}
276
+ echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
277
+
278
+ # Set asset prefix and base path with PR number
279
+ ASSET_PREFIX=https://neuralmagic.github.io/guidellm/ui/pr/${PR_NUMBER}
280
+ USE_MOCK_DATA=true
281
+ BASE_PATH=/ui/pr/${PR_NUMBER}
282
+ GIT_SHA=${{ github.sha }}
283
+ export ASSET_PREFIX=${ASSET_PREFIX}
284
+ export BASE_PATH=${BASE_PATH}
285
+ export GIT_SHA=${GIT_SHA}
286
+ export USE_MOCK_DATA=${USE_MOCK_DATA}
287
+ npm run build
288
+
289
+ - name : Deploy to GitHub Pages
290
+ if : steps.check-changes.outputs.should_build == 'true'
291
+ uses : peaceiris/actions-gh-pages@v3
292
+ with :
293
+ github_token : ${{ secrets.GITHUB_TOKEN }}
294
+ publish_dir : ./src/ui/out
295
+ destination_dir : ui/pr/${{ steps.build.outputs.pr_number }}
296
+ keep_files : false
297
+ user_name : ${{ github.actor }}
298
+ user_email : ${{ github.actor }}@users.noreply.github.com
299
+ publish_branch : gh-pages
300
+ commit_message : ' build: Deploy preview build for PR #${{ github.event.pull_request.number }}'
301
+
302
+ - name : Set deployment url
303
+ if : steps.check-changes.outputs.should_build == 'true'
304
+ id : deploy
305
+ run : |
306
+ DEPLOY_URL=https://neuralmagic.github.io/guidellm/ui/pr/${{ steps.build.outputs.pr_number }}
307
+ echo "url=${DEPLOY_URL}" >> $GITHUB_OUTPUT
308
+
309
+ - name : Find PR comment
310
+ if : steps.check-changes.outputs.should_build == 'true'
311
+ uses : peter-evans/find-comment@v2
312
+ id : find-comment
313
+ with :
314
+ token : ${{ secrets.GITHUB_TOKEN }}
315
+ issue-number : ${{ github.event.pull_request.number }}
316
+ body-includes : ' <!-- pr-preview-comment -->'
317
+
318
+ - name : Post Deployment URL to PR
319
+ if : steps.check-changes.outputs.should_build == 'true'
320
+ uses : peter-evans/create-or-update-comment@v3
321
+ with :
322
+ token : ${{ secrets.GITHUB_TOKEN }}
323
+ comment-id : ${{ steps.find-comment.outputs.comment-id }}
324
+ issue-number : ${{ github.event.pull_request.number }}
325
+ edit-mode : replace
326
+ body : |
327
+ <!-- pr-preview-comment -->
328
+ 🎉 **Live Preview:** [Click here to view the live version](${{ steps.deploy.outputs.url }})
329
+ *Last updated: ${{ github.sha }}*
330
+
331
+ - name : Skip build notification
332
+ if : steps.check-changes.outputs.should_build == 'false'
333
+ run : echo "Skipping UI preview build - no relevant files changed"
334
+
335
+ build-and-push-container :
336
+ # Only build if the PR branch is local
337
+ if : github.event.pull_request.head.repo.full_name == github.repository
338
+ runs-on : ubuntu-latest
339
+ permissions :
340
+ packages : write
341
+ steps :
342
+ - name : Checkout
343
+ uses : actions/checkout@v4
344
+ - name : Buildah build
345
+ id : build-image
346
+ uses : redhat-actions/buildah-build@v2
347
+ with :
348
+ image : ${{ github.event.repository.name }}
349
+ tags : " pr-${{ github.event.number }}"
350
+ containerfiles : |
351
+ ./deploy/Containerfile
352
+ - name : Push To ghcr.io
353
+ id : push-to-ghcr
354
+ uses : redhat-actions/push-to-registry@v2
355
+ with :
356
+ image : ${{ steps.build-image.outputs.image }}
357
+ tags : ${{ steps.build-image.outputs.tags }}
358
+ username : ${{ github.actor }}
359
+ password : ${{ github.token }}
360
+ registry : ghcr.io/${{ github.repository_owner }}
0 commit comments