Skip to content

Commit 9c0f043

Browse files
committed
update workflow to only act on ui file changes
1 parent 5eaa5b9 commit 9c0f043

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

.github/workflows/development-cleanup.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,29 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16+
- name: Check out gh-pages branch
17+
uses: actions/checkout@v3
18+
with:
19+
ref: gh-pages
20+
fetch-depth: 1
21+
22+
- name: Check if preview directory exists
23+
id: check-preview
24+
run: |
25+
if [ -d "ui/pr/${{ github.event.pull_request.number }}" ]; then
26+
echo "preview_exists=true" >> $GITHUB_OUTPUT
27+
echo "Preview directory exists for PR #${{ github.event.pull_request.number }}"
28+
else
29+
echo "preview_exists=false" >> $GITHUB_OUTPUT
30+
echo "No preview directory found for PR #${{ github.event.pull_request.number }}"
31+
fi
32+
1633
- name: Create an empty directory for cleanup
34+
if: steps.check-preview.outputs.preview_exists == 'true'
1735
run: mkdir -p empty
1836

1937
- name: Remove GitHub Pages Build
38+
if: steps.check-preview.outputs.preview_exists == 'true'
2039
uses: peaceiris/actions-gh-pages@v3
2140
with:
2241
github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -58,3 +77,11 @@ jobs:
5877
body: |
5978
<!-- pr-preview-comment -->
6079
🧹 The live preview for this PR has been removed.
80+
81+
- name: Log comment update status
82+
run: |
83+
if [ "${{ steps.find-comment.outputs.comment-id }}" != "" ]; then
84+
echo "Updated existing preview comment"
85+
else
86+
echo "No preview comment found to update"
87+
fi

.github/workflows/development.yml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,48 @@ jobs:
216216
steps:
217217
- name: Check out code
218218
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"
219254
220255
- name: Install dependencies
256+
if: steps.check-changes.outputs.should_build == 'true'
221257
run: npm ci
222258

223259
- name: Build app to root
260+
if: steps.check-changes.outputs.should_build == 'true'
224261
id: build
225262
run: |
226263
# Export vars to ensure they are loaded before build
@@ -241,6 +278,7 @@ jobs:
241278
npm run build
242279
243280
- name: Deploy to GitHub Pages
281+
if: steps.check-changes.outputs.should_build == 'true'
244282
uses: peaceiris/actions-gh-pages@v3
245283
with:
246284
github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -253,12 +291,14 @@ jobs:
253291
commit_message: 'build: Deploy preview build for PR #${{ github.event.pull_request.number }}'
254292

255293
- name: Set deployment url
294+
if: steps.check-changes.outputs.should_build == 'true'
256295
id: deploy
257296
run: |
258297
DEPLOY_URL=https://neuralmagic.github.io/guidellm/ui/pr/${{ steps.build.outputs.pr_number }}
259298
echo "url=${DEPLOY_URL}" >> $GITHUB_OUTPUT
260299
261300
- name: Find PR comment
301+
if: steps.check-changes.outputs.should_build == 'true'
262302
uses: peter-evans/find-comment@v2
263303
id: find-comment
264304
with:
@@ -267,6 +307,7 @@ jobs:
267307
body-includes: '<!-- pr-preview-comment -->'
268308

269309
- name: Post Deployment URL to PR
310+
if: steps.check-changes.outputs.should_build == 'true'
270311
uses: peter-evans/create-or-update-comment@v3
271312
with:
272313
token: ${{ secrets.GITHUB_TOKEN }}
@@ -276,4 +317,8 @@ jobs:
276317
body: |
277318
<!-- pr-preview-comment -->
278319
🎉 **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

Comments
 (0)