-
Notifications
You must be signed in to change notification settings - Fork 142
170 lines (150 loc) · 5.44 KB
/
development.yml
File metadata and controls
170 lines (150 loc) · 5.44 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Development
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
tests:
strategy:
matrix:
python: ["3.10"]
uses: ./.github/workflows/testing.yml
with:
python: ${{ matrix.python }}
ui-tests:
uses: ./.github/workflows/ui-testing.yml
quality:
strategy:
matrix:
python: ["3.10"]
uses: ./.github/workflows/quality.yml
with:
python: ${{ matrix.python }}
ui-quality:
uses: ./.github/workflows/ui-quality.yml
ui-pr-preview:
needs: [ui-quality, ui-tests]
permissions:
contents: write
pull-requests: write
issues: write
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Node.js 22
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Check if UI-related files changed
id: check-changes
run: |
BASE_BRANCH=${{ github.event.pull_request.base.ref }}
CHANGED_FILES=$(git diff --name-only origin/$BASE_BRANCH...HEAD)
SHOULD_BUILD=false
if echo "$CHANGED_FILES" | grep -q "^src/ui/"; then
echo "UI source files changed"
SHOULD_BUILD=true
fi
echo "should_build=$SHOULD_BUILD" >> $GITHUB_OUTPUT
echo "Should build: $SHOULD_BUILD"
- name: Install dependencies
if: steps.check-changes.outputs.should_build == 'true'
run: npm ci
- name: Build app to root
if: steps.check-changes.outputs.should_build == 'true'
id: build
run: |
# Export vars to ensure they are loaded before build
export $(grep -v '^#' .env.development | xargs)
PR_NUMBER=${{ github.event.pull_request.number }}
echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
# Set asset prefix and base path with PR number
ASSET_PREFIX=https://blog.vllm.ai/guidellm/ui/pr/${PR_NUMBER}
USE_MOCK_DATA=true
BASE_PATH=/ui/pr/${PR_NUMBER}
GIT_SHA=${{ github.sha }}
export ASSET_PREFIX=${ASSET_PREFIX}
export BASE_PATH=${BASE_PATH}
export GIT_SHA=${GIT_SHA}
export USE_MOCK_DATA=${USE_MOCK_DATA}
npm run build
- name: Deploy to GitHub Pages
if: steps.check-changes.outputs.should_build == 'true'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./src/ui/out
destination_dir: ui/pr/${{ steps.build.outputs.pr_number }}
keep_files: false
user_name: ${{ github.actor }}
user_email: ${{ github.actor }}@users.noreply.github.com
publish_branch: gh-pages
commit_message: 'build: Deploy preview build for PR #${{ github.event.pull_request.number }}'
- name: Set deployment url
if: steps.check-changes.outputs.should_build == 'true'
id: deploy
run: |
DEPLOY_URL=https://blog.vllm.ai/guidellm/ui/pr/${{ steps.build.outputs.pr_number }}
echo "url=${DEPLOY_URL}" >> $GITHUB_OUTPUT
- name: Find PR comment
if: steps.check-changes.outputs.should_build == 'true'
uses: peter-evans/find-comment@v2
id: find-comment
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body-includes: '<!-- pr-preview-comment -->'
- name: Post Deployment URL to PR
if: steps.check-changes.outputs.should_build == 'true'
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
<!-- pr-preview-comment -->
🎉 **Live Preview:** [Click here to view the live version](${{ steps.deploy.outputs.url }})
*Last updated: ${{ github.sha }}*
- name: Skip build notification
if: steps.check-changes.outputs.should_build == 'false'
run: echo "Skipping UI preview build - no relevant files changed"
build-and-push-container:
# Only build if the PR branch is local
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Store/retrieve build caches
id: cache-buildah
uses: actions/cache@v4
with:
path: /var/tmp/buildah-cache-*
key: buildah-mount-cache-${{ runner.os }}-${{ runner.arch }}
- name: Buildah build
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ github.event.repository.name }}
build-args: |
GUIDELLM_BUILD_TYPE=dev
tags: "pr-${{ github.event.number }}"
layers: true
containerfiles: |
./Containerfile
- name: Push To ghcr.io
id: push-to-ghcr
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
username: ${{ github.actor }}
password: ${{ github.token }}
registry: ghcr.io/${{ github.repository_owner }}