13
13
GH_TOKEN : ${{ secrets.GH_TOKEN }}
14
14
15
15
jobs :
16
+ configure-branch-name :
17
+ name : ' Configure Head Branch Name'
18
+ runs-on : ubuntu-latest
19
+ outputs :
20
+ gh_head_ref : ${{ steps.configure-branch-name.outputs.gh_head_ref }}
21
+ steps :
22
+ - name : Configure branch name
23
+ id : configure-branch-name
24
+ run : echo "gh_head_ref=$(echo "${{ github.event.pull_request.head.ref }}" | sed 's|/|-|g')" >> $GITHUB_OUTPUT
25
+
26
+ pi-matrix :
27
+ uses : code-kern-ai/cicd-deployment-scripts/.github/workflows/pi_matrix.yml@dev
28
+ secrets : inherit
29
+ with :
30
+ checkout_ref : ${{ github.event.pull_request.base.ref }}
31
+ repository : " ${{ github.repository_owner }}/refinery-submodule-parent-images"
32
+ parent_image_type : ${{ vars.PARENT_IMAGE_TYPE }}
33
+
16
34
pi-build :
17
35
name : ' Parent Images: Docker Build'
18
36
runs-on : ubuntu-latest
@@ -116,6 +134,109 @@ jobs:
116
134
platform=linux/arm64
117
135
label=dockerfile-path=https://github.com/refinery-${{ env.PARENT_IMAGE_TYPE }}-parent-image/blob/${{ github.sha }}/Dockerfile
118
136
137
+ pi-update-app :
138
+ name : ' Parent Images: App'
139
+ runs-on : ubuntu-latest
140
+ needs : [pi-matrix, configure-branch-name, pi-build]
141
+ environment : dev
142
+ continue-on-error : true
143
+ env :
144
+ PYTHON_VERSION : ${{ vars.PYTHON_VERSION }}
145
+ strategy :
146
+ matrix :
147
+ include : ${{ fromJson(needs.pi-matrix.outputs.include) }}
148
+ steps :
149
+ - name : Checkout Repository
150
+ uses : actions/checkout@v4
151
+ with :
152
+ submodules : ' true'
153
+
154
+ - name : Set up Python
155
+ if : matrix.parent_image_type != 'next'
156
+ uses : actions/setup-python@v5
157
+ with :
158
+ python-version : ${{ env.PYTHON_VERSION }}
159
+
160
+ - name : Install Dependencies
161
+ if : matrix.parent_image_type != 'next'
162
+ run : python -m pip install pip-tools
163
+
164
+ - name : Clone ${{ matrix.app }}
165
+ run : |
166
+ git clone https://oauth2:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository_owner }}/${{ matrix.app }}.git
167
+ cd ${{ github.workspace }}/${{ matrix.app }}
168
+
169
+ git config user.email "devtools@kern.ai"
170
+ git config user.name "GitHub Actions"
171
+
172
+ git checkout -b ${{ needs.configure-branch-name.outputs.gh_head_ref }} || git checkout ${{ needs.configure-branch-name.outputs.gh_head_ref }}
173
+ git pull origin ${{ needs.configure-branch-name.outputs.gh_head_ref }}
174
+
175
+ - name : Compile Requirements (Python)
176
+ if : matrix.parent_image_type != 'next'
177
+ run : |
178
+ pip-compile --quiet \
179
+ --output-file ${{ matrix.app }}/requirements/${{ matrix.parent_image_type }}-requirements.txt \
180
+ submodules/parent-images/requirements/${{ matrix.parent_image_type }}-requirements.in
181
+
182
+ - name : Compile Requirements (Next)
183
+ if : matrix.parent_image_type == 'next'
184
+ run : |
185
+ jq --slurp '.[0] * .[1]' \
186
+ package.json \
187
+ ${{ matrix.app }}/package.json \
188
+ > package.json.tmp
189
+ mv package.json.tmp ${{ matrix.app }}/package.json
190
+
191
+ - name : Perform Edit/Git Operations (Python)
192
+ if : matrix.parent_image_type != 'next'
193
+ run : |
194
+ cd ${{ github.workspace }}/${{ matrix.app }}
195
+
196
+ git add requirements/${{ matrix.parent_image_type }}-requirements.in
197
+ git commit -m "ci: update ${{ matrix.parent_image_type }}-requirements.txt" || true
198
+ git push origin ${{ needs.configure-branch-name.outputs.gh_head_ref }}
199
+ echo "::notice::${{ matrix.app }} - updated ${{ matrix.parent_image_type }}-requirements.txt"
200
+
201
+ export exitcode=0
202
+ pip-compile --quiet \
203
+ --output-file requirements.txt \
204
+ requirements/requirements.in || export exitcode=$?
205
+
206
+ if [ $exitcode -ne 0 ]; then
207
+ echo "::error::pip-compile failed with exit code $exitcode"
208
+ exit $exitcode
209
+ else
210
+ git add requirements.txt
211
+ git commit -m "ci: update requirements.txt" || true
212
+ git push origin ${{ needs.configure-branch-name.outputs.gh_head_ref }}
213
+ echo "::notice::${{ matrix.app }} - updated requirements.txt"
214
+ fi
215
+
216
+ gh pr create --draft \
217
+ --title "${{ github.event.pull_request.title }}" \
218
+ --body "${{ github.event.pull_request.body }}" \
219
+ --base dev \
220
+ --head ${{ needs.configure-branch-name.outputs.gh_head_ref }} \
221
+ --repo ${{ github.repository_owner }}/${{ matrix.app }} || true
222
+
223
+ - name : Perform Edit/Git Operations (Next)
224
+ if : matrix.parent_image_type == 'next'
225
+ run : |
226
+ cd ${{ github.workspace }}/${{ matrix.app }}
227
+
228
+ git add package.json
229
+ git commit -m "ci: update ${{ matrix.parent_image_type }} package.json" || true
230
+ git push origin ${{ needs.configure-branch-name.outputs.gh_head_ref }}
231
+ echo "::notice::${{ matrix.app }} - updated ${{ matrix.parent_image_type }} package.json"
232
+
233
+ gh pr create --draft \
234
+ --title "${{ github.event.pull_request.title }}" \
235
+ --body "${{ github.event.pull_request.body }}" \
236
+ --base dev \
237
+ --head ${{ needs.configure-branch-name.outputs.gh_head_ref }} \
238
+ --repo ${{ github.repository_owner }}/${{ matrix.app }} || true
239
+
119
240
gh-delete-branch :
120
241
name : ' GitHub: Delete Branch'
121
242
needs : [pi-build]
@@ -127,6 +248,25 @@ jobs:
127
248
with :
128
249
token : ${{ secrets.GH_TOKEN }}
129
250
251
+ - name : Delete Branch
252
+ shell : bash
253
+ run : git push origin --delete ${{ github.event.pull_request.head.ref }}
254
+
255
+ gh-delete-app-branches :
256
+ name : ' GitHub: Delete Branch'
257
+ needs : [pi-matrix, pi-update-app]
258
+ if : !failure()
259
+ runs-on : ubuntu-latest
260
+ strategy :
261
+ matrix :
262
+ include : ${{ fromJson(needs.pi-matrix.outputs.include) }}
263
+ steps :
264
+ - name : Checkout repository
265
+ uses : actions/checkout@v4
266
+ with :
267
+ token : ${{ secrets.GH_TOKEN }}
268
+ repository : ' ${{ github.repository_owner }}/${{ matrix.app }}'
269
+
130
270
- name : Delete Branch
131
271
shell : bash
132
272
run : git push origin --delete ${{ github.event.pull_request.head.ref }}
0 commit comments