Skip to content

Commit f7cf884

Browse files
committed
feat(app-update): separate smodules merge from parent images merge
1 parent df417ef commit f7cf884

File tree

2 files changed

+141
-121
lines changed

2 files changed

+141
-121
lines changed

.github/workflows/pi_merge_parent_image.yml

+140
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ env:
1313
GH_TOKEN: ${{ secrets.GH_TOKEN }}
1414

1515
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+
1634
pi-build:
1735
name: 'Parent Images: Docker Build'
1836
runs-on: ubuntu-latest
@@ -116,6 +134,109 @@ jobs:
116134
platform=linux/arm64
117135
label=dockerfile-path=https://github.com/refinery-${{ env.PARENT_IMAGE_TYPE }}-parent-image/blob/${{ github.sha }}/Dockerfile
118136
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+
119240
gh-delete-branch:
120241
name: 'GitHub: Delete Branch'
121242
needs: [pi-build]
@@ -127,6 +248,25 @@ jobs:
127248
with:
128249
token: ${{ secrets.GH_TOKEN }}
129250

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+
130270
- name: Delete Branch
131271
shell: bash
132272
run: git push origin --delete ${{ github.event.pull_request.head.ref }}

.github/workflows/pi_merge_submodule.yml

+1-121
Original file line numberDiff line numberDiff line change
@@ -81,111 +81,10 @@ jobs:
8181
--head ${{ needs.configure-branch-name.outputs.gh_head_ref }} \
8282
--repo ${{ github.repository_owner }}/refinery-${{ matrix.parent_image_type }}-parent-image || true
8383
84-
pi-update-app:
85-
name: 'Parent Images: App'
86-
runs-on: ubuntu-latest
87-
needs: [pi-matrix, configure-branch-name, pi-update-submodule]
88-
environment: dev
89-
continue-on-error: true
90-
env:
91-
PYTHON_VERSION: ${{ vars.PYTHON_VERSION }}
92-
strategy:
93-
matrix:
94-
include: ${{ fromJson(needs.pi-matrix.outputs.include) }}
95-
steps:
96-
- name: Checkout Repository
97-
uses: actions/checkout@v4
98-
with:
99-
repository: '${{ github.repository_owner }}/refinery-${{ matrix.parent_image_type }}-parent-image'
100-
submodules: 'true'
101-
102-
- name: Set up Python
103-
uses: actions/setup-python@v5
104-
with:
105-
python-version: ${{ env.PYTHON_VERSION }}
106-
107-
- name: Install Dependencies
108-
run: python -m pip install pip-tools
109-
110-
- name: Clone ${{ matrix.app }}
111-
run: |
112-
git clone https://oauth2:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository_owner }}/${{ matrix.app }}.git
113-
cd ${{ github.workspace }}/${{ matrix.app }}
114-
115-
git config user.email "devtools@kern.ai"
116-
git config user.name "GitHub Actions"
117-
118-
git checkout -b ${{ needs.configure-branch-name.outputs.gh_head_ref }} || git checkout ${{ needs.configure-branch-name.outputs.gh_head_ref }}
119-
git pull origin ${{ needs.configure-branch-name.outputs.gh_head_ref }}
120-
121-
- name: Compile Requirements (Python)
122-
if: matrix.parent_image_type != 'next'
123-
run: |
124-
pip-compile --quiet \
125-
--output-file ${{ matrix.app }}/requirements/${{ matrix.parent_image_type }}-requirements.txt \
126-
submodules/parent-images/requirements/${{ matrix.parent_image_type }}-requirements.in
127-
128-
- name: Compile Requirements (Next)
129-
if: matrix.parent_image_type == 'next'
130-
run: |
131-
jq --slurp '.[0] * .[1]' \
132-
package.json \
133-
${{ matrix.app }}/package.json \
134-
> package.json.tmp
135-
mv package.json.tmp ${{ matrix.app }}/package.json
136-
137-
- name: Perform Edit/Git Operations (Python)
138-
if: matrix.parent_image_type != 'next'
139-
run: |
140-
cd ${{ github.workspace }}/${{ matrix.app }}
141-
142-
git add requirements/${{ matrix.parent_image_type }}-requirements.in
143-
git commit -m "ci: update ${{ matrix.parent_image_type }}-requirements.txt" || true
144-
git push origin ${{ needs.configure-branch-name.outputs.gh_head_ref }}
145-
echo "::notice::${{ matrix.app }} - updated ${{ matrix.parent_image_type }}-requirements.txt"
146-
147-
export exitcode=0
148-
pip-compile --quiet \
149-
--output-file requirements.txt \
150-
requirements/requirements.in || export exitcode=$?
151-
152-
if [ $exitcode -ne 0 ]; then
153-
echo "::error::pip-compile failed with exit code $exitcode"
154-
exit $exitcode
155-
else
156-
git add requirements.txt
157-
git commit -m "ci: update requirements.txt" || true
158-
git push origin ${{ needs.configure-branch-name.outputs.gh_head_ref }}
159-
echo "::notice::${{ matrix.app }} - updated requirements.txt"
160-
fi
161-
162-
gh pr create --draft \
163-
--title "${{ github.event.pull_request.title }}" \
164-
--body "${{ github.event.pull_request.body }}" \
165-
--base dev \
166-
--head ${{ needs.configure-branch-name.outputs.gh_head_ref }} \
167-
--repo ${{ github.repository_owner }}/${{ matrix.app }} || true
168-
169-
- name: Perform Edit/Git Operations (Next)
170-
if: matrix.parent_image_type == 'next'
171-
run: |
172-
cd ${{ github.workspace }}/${{ matrix.app }}
173-
174-
git add package.json
175-
git commit -m "ci: update ${{ matrix.parent_image_type }} package.json" || true
176-
git push origin ${{ needs.configure-branch-name.outputs.gh_head_ref }}
177-
echo "::notice::${{ matrix.app }} - updated ${{ matrix.parent_image_type }} package.json"
178-
179-
gh pr create --draft \
180-
--title "${{ github.event.pull_request.title }}" \
181-
--body "${{ github.event.pull_request.body }}" \
182-
--base dev \
183-
--head ${{ needs.configure-branch-name.outputs.gh_head_ref }} \
184-
--repo ${{ github.repository_owner }}/${{ matrix.app }} || true
18584
18685
gh-delete-submodule-branches:
18786
name: 'GitHub: Delete Branch'
188-
needs: [pi-matrix, pi-update-submodule, pi-update-app]
87+
needs: [pi-matrix, pi-update-submodule]
18988
if: !failure()
19089
runs-on: ubuntu-latest
19190
strategy:
@@ -198,25 +97,6 @@ jobs:
19897
token: ${{ secrets.GH_TOKEN }}
19998
repository: '${{ github.repository_owner }}/refinery-${{ matrix.parent_image_type }}-parent-image'
20099

201-
- name: Delete Branch
202-
shell: bash
203-
run: git push origin --delete ${{ github.event.pull_request.head.ref }}
204-
205-
gh-delete-app-branches:
206-
name: 'GitHub: Delete Branch'
207-
needs: [pi-matrix, pi-update-submodule, pi-update-app]
208-
if: !failure()
209-
runs-on: ubuntu-latest
210-
strategy:
211-
matrix:
212-
include: ${{ fromJson(needs.pi-matrix.outputs.include) }}
213-
steps:
214-
- name: Checkout repository
215-
uses: actions/checkout@v4
216-
with:
217-
token: ${{ secrets.GH_TOKEN }}
218-
repository: '${{ github.repository_owner }}/${{ matrix.app }}'
219-
220100
- name: Delete Branch
221101
shell: bash
222102
run: git push origin --delete ${{ github.event.pull_request.head.ref }}

0 commit comments

Comments
 (0)