Skip to content

Commit 1634979

Browse files
committed
perf: apply testing changes to app repos
1 parent 468e213 commit 1634979

File tree

1 file changed

+144
-13
lines changed

1 file changed

+144
-13
lines changed

.github/workflows/pi_build.yml

+144-13
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
DEV_CONTAINER_REGISTRY: ${{ vars.DEV_CONTAINER_REGISTRY }}
4242
DEV_LOGIN_USERNAME: ${{ secrets.DEV_LOGIN_USERNAME }}
4343
DEV_LOGIN_PASSWORD: ${{ secrets.DEV_LOGIN_PASSWORD }}
44+
PARENT_IMAGE_NAME: ${{ vars.PARENT_IMAGE_NAME }}
45+
DOCKERFILE: ${{ vars.DOCKERFILE }}
46+
HEAD_REF: ${{ needs.configure-branch-name.outputs.gh_head_ref }}
4447
IMAGE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || needs.configure-branch-name.outputs.gh_head_ref }}
4548
strategy:
4649
matrix:
@@ -65,7 +68,7 @@ jobs:
6568
- name: Compile Requirements
6669
run: |
6770
cd ${{ github.workspace }}/submodules/parent-images
68-
git checkout ${{ needs.configure-branch-name.outputs.gh_head_ref }}
71+
git checkout ${{ env.HEAD_REF }}
6972
pip-compile requirements/${{ matrix.parent_image_type }}-requirements.in
7073
7174
- name: Set up Docker Buildx
@@ -85,30 +88,158 @@ jobs:
8588
username: "${{ env.DEV_LOGIN_USERNAME }}"
8689
password: "${{ env.DEV_LOGIN_PASSWORD }}"
8790

88-
- name: Build & Push refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ matrix.parent_image_type }}
91+
- name: Build & Push ${{ env.PARENT_IMAGE_NAME }}:${{ env.HEAD_REF }}-${{ matrix.parent_image_type }}
8992
uses: docker/build-push-action@v5
9093
with:
9194
context: .
92-
cache-from: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ matrix.parent_image_type }}-cache
93-
cache-to: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ matrix.parent_image_type }}-cache,mode=max,image-manifest=true
95+
cache-from: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/${{ env.PARENT_IMAGE_NAME }}:${{ env.HEAD_REF }}-${{ matrix.parent_image_type }}-cache
96+
cache-to: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/${{ env.PARENT_IMAGE_NAME }}:${{ env.HEAD_REF }}-${{ matrix.parent_image_type }}-cache,mode=max,image-manifest=true
9497
platforms: linux/amd64
95-
file: Dockerfile
96-
tags: ${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ matrix.parent_image_type }}
98+
file: ${{ env.DOCKERFILE }}
99+
tags: ${{ env.DEV_CONTAINER_REGISTRY }}/${{ env.PARENT_IMAGE_NAME }}:${{ env.HEAD_REF }}-${{ matrix.parent_image_type }}
97100
push: true
98101
build-args: |
99102
platform=linux/amd64
100-
label=dockerfile-path=https://github.com/refinery-${{ matrix.parent_image_type }}-parent-image/blob/${{ github.sha }}/Dockerfile
103+
label=dockerfile-path=https://github.com/refinery-${{ matrix.parent_image_type }}-parent-image/blob/${{ github.sha }}/${{ env.DOCKERFILE }}
101104
102-
- name: Build & Push refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ matrix.parent_image_type }}-arm64
105+
- name: Build & Push ${{ env.PARENT_IMAGE_NAME }}:${{ env.HEAD_REF }}-${{ matrix.parent_image_type }}-arm64
103106
uses: docker/build-push-action@v5
104107
with:
105108
context: .
106-
cache-from: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ matrix.parent_image_type }}-arm64-cache
107-
cache-to: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ matrix.parent_image_type }}-arm64-cache,mode=max,image-manifest=true
109+
cache-from: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/${{ env.PARENT_IMAGE_NAME }}:${{ env.HEAD_REF }}-${{ matrix.parent_image_type }}-arm64-cache
110+
cache-to: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/${{ env.PARENT_IMAGE_NAME }}:${{ env.HEAD_REF }}-${{ matrix.parent_image_type }}-arm64-cache,mode=max,image-manifest=true
108111
platforms: linux/arm64
109-
file: Dockerfile
110-
tags: ${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ matrix.parent_image_type }}-arm64
112+
file: ${{ env.DOCKERFILE }}
113+
tags: ${{ env.DEV_CONTAINER_REGISTRY }}/${{ env.PARENT_IMAGE_NAME }}:${{ env.HEAD_REF }}-${{ matrix.parent_image_type }}-arm64
111114
push: true
112115
build-args: |
113116
platform=linux/arm64
114-
label=dockerfile-path=https://github.com/refinery-${{ matrix.parent_image_type }}-parent-image/blob/${{ github.sha }}/Dockerfile
117+
label=dockerfile-path=https://github.com/refinery-${{ matrix.parent_image_type }}-parent-image/blob/${{ github.sha }}/${{ env.DOCKERFILE }}
118+
119+
pi-update-app:
120+
name: 'Parent Images: App'
121+
runs-on: ubuntu-latest
122+
needs: [pi-matrix, pi-build, configure-branch-name]
123+
environment: dev
124+
continue-on-error: true
125+
env:
126+
PYTHON_VERSION: ${{ vars.PYTHON_VERSION }}
127+
DEV_CONTAINER_REGISTRY: ${{ vars.DEV_CONTAINER_REGISTRY }}
128+
PARENT_IMAGE_NAME: ${{ vars.PARENT_IMAGE_NAME }}
129+
DOCKERFILE: ${{ vars.DOCKERFILE }}
130+
HEAD_REF: ${{ needs.configure-branch-name.outputs.gh_head_ref }}
131+
strategy:
132+
matrix:
133+
include: ${{ fromJson(needs.pi-matrix.outputs.include) }}
134+
steps:
135+
- name: Checkout Repository
136+
uses: actions/checkout@v4
137+
with:
138+
submodules: 'true'
139+
140+
- name: Set up Python
141+
if: matrix.parent_image_type != 'next'
142+
uses: actions/setup-python@v5
143+
with:
144+
python-version: ${{ env.PYTHON_VERSION }}
145+
146+
- name: Install Dependencies
147+
if: matrix.parent_image_type != 'next'
148+
run: python -m pip install pip-tools
149+
150+
- name: Clone cicd-deployment-scripts
151+
run: git clone https://oauth2:${{ secrets.GH_TOKEN }}@github.com/code-kern-ai/cicd-deployment-scripts.git
152+
153+
- name: Clone ${{ matrix.app }}
154+
run: |
155+
git clone --recurse-submodules https://oauth2:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository_owner }}/${{ matrix.app }}.git
156+
cd ${{ github.workspace }}/${{ matrix.app }}
157+
158+
git config user.email "[email protected]"
159+
git config user.name "GitHub Actions"
160+
161+
git checkout -b ${{ env.HEAD_REF }} || git checkout ${{ env.HEAD_REF }}
162+
163+
- name: Compile Requirements (Python)
164+
if: matrix.parent_image_type != 'next'
165+
run: |
166+
cd ${{ github.workspace }}/${{ matrix.app }}/submodules/parent-images
167+
git checkout ${{ env.HEAD_REF }}
168+
cd ${{ github.workspace }}/${{ matrix.app }}
169+
pip-compile --quiet \
170+
--output-file requirements/${{ matrix.parent_image_type }}-requirements.txt \
171+
submodules/parent-images/requirements/${{ matrix.parent_image_type }}-requirements.in
172+
173+
- name: Compile Requirements (Next)
174+
if: matrix.parent_image_type == 'next'
175+
run: |
176+
cd ${{ github.workspace }}
177+
jq --slurp '.[0] * .[1]' \
178+
package.json \
179+
${{ matrix.app }}/package.json \
180+
> package.json.tmp
181+
mv package.json.tmp ${{ matrix.app }}/package.json
182+
183+
- name: Perform Edit/Git Operations (Python)
184+
if: matrix.parent_image_type != 'next'
185+
run: |
186+
cd ${{ github.workspace }}/${{ matrix.app }}
187+
188+
bash ${{ github.workspace }}/cicd-deployment-scripts/pi/edit_dockerfile.sh \
189+
-i "${{ env.PARENT_IMAGE_NAME }}" \
190+
-t "${{ matrix.parent_image_type }}" \
191+
-l "${{ env.HEAD_REF }}" \
192+
-r "${{ env.DEV_CONTAINER_REGISTRY }}" \
193+
-d "${{ env.DOCKERFILE }}"
194+
195+
git add requirements/${{ matrix.parent_image_type }}-requirements.txt
196+
git commit -m "ci: update ${{ matrix.parent_image_type }}-requirements.txt" || true
197+
git push origin ${{ env.HEAD_REF }}
198+
echo "::notice::${{ matrix.app }} - updated ${{ matrix.parent_image_type }}-requirements.txt"
199+
200+
export exitcode=0
201+
pip-compile --quiet \
202+
--output-file requirements.txt \
203+
requirements/requirements.in || export exitcode=$?
204+
205+
if [ $exitcode -ne 0 ]; then
206+
echo "::error::pip-compile failed with exit code $exitcode"
207+
exit $exitcode
208+
else
209+
git add requirements.txt
210+
git commit -m "ci: update requirements.txt" || true
211+
git push origin ${{ env.HEAD_REF }}
212+
echo "::notice::${{ matrix.app }} - updated requirements.txt"
213+
fi
214+
215+
gh pr create --draft \
216+
--title "${{ github.event.pull_request.title }}" \
217+
--body "${{ github.event.pull_request.body }}" \
218+
--base dev \
219+
--head ${{ env.HEAD_REF }} \
220+
--repo ${{ github.repository_owner }}/${{ matrix.app }} || true
221+
222+
- name: Perform Edit/Git Operations (Next)
223+
if: matrix.parent_image_type == 'next'
224+
run: |
225+
cd ${{ github.workspace }}/${{ matrix.app }}
226+
227+
bash ${{ github.workspace }}/cicd-deployment-scripts/pi/edit_dockerfile.sh \
228+
-i "${{ env.PARENT_IMAGE_NAME }}" \
229+
-t "${{ matrix.parent_image_type }}" \
230+
-l "${{ env.HEAD_REF }}" \
231+
-r "${{ env.DEV_CONTAINER_REGISTRY }}" \
232+
-d "${{ env.DOCKERFILE }}"
233+
234+
git add package.json
235+
git commit -m "ci: update ${{ matrix.parent_image_type }} package.json" || true
236+
git push origin ${{ env.HEAD_REF }}
237+
echo "::notice::${{ matrix.app }} - updated ${{ matrix.parent_image_type }} package.json"
238+
239+
gh pr create --draft \
240+
--title "${{ github.event.pull_request.title }}" \
241+
--body "${{ github.event.pull_request.body }}" \
242+
--base dev \
243+
--head ${{ env.HEAD_REF }} \
244+
--repo ${{ github.repository_owner }}/${{ matrix.app }} || true
245+

0 commit comments

Comments
 (0)