@@ -216,11 +216,48 @@ jobs:
216
216
steps :
217
217
- name : Check out code
218
218
uses : actions/checkout@v3
219
+ with :
220
+ fetch-depth : 0
221
+
222
+ - name : Check if UI-related files changed
223
+ id : check-changes
224
+ run : |
225
+ # Get the base branch
226
+ BASE_BRANCH=${{ github.event.pull_request.base.ref }}
227
+
228
+ # Get list of changed files
229
+ CHANGED_FILES=$(git diff --name-only origin/$BASE_BRANCH...HEAD)
230
+
231
+ # Define the files we care about in root
232
+ ROOT_FILES="package.json package-lock.json jest.config.cjs jest.setup.ts eslint.config.js cypress.config.ts .prettierrc .prettierignore tsconfig.json tsconfig.base.json tsconfig.test.json tsconfig.cypress.json"
233
+
234
+ # Check if src/ui directory changed or any of the root files changed
235
+ SHOULD_BUILD=false
236
+
237
+ # Check if any file in src/ui changed
238
+ if echo "$CHANGED_FILES" | grep -q -E "^(src/ui|tests/ui)/"; then
239
+ echo "UI source files changed"
240
+ SHOULD_BUILD=true
241
+ fi
242
+
243
+ # Check if any of the root configuration files changed
244
+ for file in $ROOT_FILES; do
245
+ if echo "$CHANGED_FILES" | grep -q "^${file}$"; then
246
+ echo "Root config file changed: $file"
247
+ SHOULD_BUILD=true
248
+ break
249
+ fi
250
+ done
251
+
252
+ echo "should_build=$SHOULD_BUILD" >> $GITHUB_OUTPUT
253
+ echo "Should build: $SHOULD_BUILD"
219
254
220
255
- name : Install dependencies
256
+ if : steps.check-changes.outputs.should_build == 'true'
221
257
run : npm ci
222
258
223
259
- name : Build app to root
260
+ if : steps.check-changes.outputs.should_build == 'true'
224
261
id : build
225
262
run : |
226
263
# Export vars to ensure they are loaded before build
@@ -241,6 +278,7 @@ jobs:
241
278
npm run build
242
279
243
280
- name : Deploy to GitHub Pages
281
+ if : steps.check-changes.outputs.should_build == 'true'
244
282
uses : peaceiris/actions-gh-pages@v3
245
283
with :
246
284
github_token : ${{ secrets.GITHUB_TOKEN }}
@@ -253,12 +291,14 @@ jobs:
253
291
commit_message : ' build: Deploy preview build for PR #${{ github.event.pull_request.number }}'
254
292
255
293
- name : Set deployment url
294
+ if : steps.check-changes.outputs.should_build == 'true'
256
295
id : deploy
257
296
run : |
258
297
DEPLOY_URL=https://neuralmagic.github.io/guidellm/ui/pr/${{ steps.build.outputs.pr_number }}
259
298
echo "url=${DEPLOY_URL}" >> $GITHUB_OUTPUT
260
299
261
300
- name : Find PR comment
301
+ if : steps.check-changes.outputs.should_build == 'true'
262
302
uses : peter-evans/find-comment@v2
263
303
id : find-comment
264
304
with :
@@ -267,6 +307,7 @@ jobs:
267
307
body-includes : ' <!-- pr-preview-comment -->'
268
308
269
309
- name : Post Deployment URL to PR
310
+ if : steps.check-changes.outputs.should_build == 'true'
270
311
uses : peter-evans/create-or-update-comment@v3
271
312
with :
272
313
token : ${{ secrets.GITHUB_TOKEN }}
@@ -276,4 +317,8 @@ jobs:
276
317
body : |
277
318
<!-- pr-preview-comment -->
278
319
🎉 **Live Preview:** [Click here to view the live version](${{ steps.deploy.outputs.url }})
279
- *Last updated: ${{ github.sha }}*
320
+ *Last updated: ${{ github.sha }}*
321
+
322
+ - name : Skip build notification
323
+ if : steps.check-changes.outputs.should_build == 'false'
324
+ run : echo "Skipping UI preview build - no relevant files changed"
0 commit comments