Skip to content

Commit 876d7d2

Browse files
committed
fix: update git operations in pi workflows
1 parent f40bf03 commit 876d7d2

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

.github/workflows/pi_merge_parent_image.yml

+8-17
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@ 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-
2616
pi-matrix:
2717
uses: code-kern-ai/cicd-deployment-scripts/.github/workflows/pi_matrix.yml@dev
2818
secrets: inherit
@@ -138,11 +128,12 @@ jobs:
138128
pi-update-app:
139129
name: 'Parent Images: App'
140130
runs-on: ubuntu-latest
141-
needs: [pi-matrix, configure-branch-name, pi-build]
131+
needs: [pi-matrix, pi-build]
142132
environment: dev
143133
continue-on-error: true
144134
env:
145135
PYTHON_VERSION: ${{ vars.PYTHON_VERSION }}
136+
HEAD_REF: parent-image-updates
146137
strategy:
147138
matrix:
148139
include: ${{ fromJson(needs.pi-matrix.outputs.include) }}
@@ -170,7 +161,7 @@ jobs:
170161
git config user.email "[email protected]"
171162
git config user.name "GitHub Actions"
172163
173-
git checkout -b ${{ needs.configure-branch-name.outputs.gh_head_ref }} || git checkout ${{ needs.configure-branch-name.outputs.gh_head_ref }}
164+
git checkout -b ${{ env.HEAD_REF }} || git checkout ${{ env.HEAD_REF }}
174165
175166
- name: Compile Requirements (Python)
176167
if: matrix.parent_image_type != 'next'
@@ -195,7 +186,7 @@ jobs:
195186
196187
git add requirements/${{ matrix.parent_image_type }}-requirements.txt
197188
git commit -m "ci: update ${{ matrix.parent_image_type }}-requirements.txt" || true
198-
git push origin ${{ needs.configure-branch-name.outputs.gh_head_ref }}
189+
git push origin ${{ env.HEAD_REF }}
199190
echo "::notice::${{ matrix.app }} - updated ${{ matrix.parent_image_type }}-requirements.txt"
200191
201192
export exitcode=0
@@ -209,15 +200,15 @@ jobs:
209200
else
210201
git add requirements.txt
211202
git commit -m "ci: update requirements.txt" || true
212-
git push origin ${{ needs.configure-branch-name.outputs.gh_head_ref }}
203+
git push origin ${{ env.HEAD_REF }}
213204
echo "::notice::${{ matrix.app }} - updated requirements.txt"
214205
fi
215206
216207
gh pr create --draft \
217208
--title "${{ github.event.pull_request.title }}" \
218209
--body "${{ github.event.pull_request.body }}" \
219210
--base dev \
220-
--head ${{ needs.configure-branch-name.outputs.gh_head_ref }} \
211+
--head ${{ env.HEAD_REF }} \
221212
--repo ${{ github.repository_owner }}/${{ matrix.app }} || true
222213
223214
- name: Perform Edit/Git Operations (Next)
@@ -227,14 +218,14 @@ jobs:
227218
228219
git add package.json
229220
git commit -m "ci: update ${{ matrix.parent_image_type }} package.json" || true
230-
git push origin ${{ needs.configure-branch-name.outputs.gh_head_ref }}
221+
git push origin ${{ env.HEAD_REF }}
231222
echo "::notice::${{ matrix.app }} - updated ${{ matrix.parent_image_type }} package.json"
232223
233224
gh pr create --draft \
234225
--title "${{ github.event.pull_request.title }}" \
235226
--body "${{ github.event.pull_request.body }}" \
236227
--base dev \
237-
--head ${{ needs.configure-branch-name.outputs.gh_head_ref }} \
228+
--head ${{ env.HEAD_REF }} \
238229
--repo ${{ github.repository_owner }}/${{ matrix.app }} || true
239230
240231
gh-delete-branch:

.github/workflows/pi_release.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
PARENT_IMAGE_NAME: ${{ vars.PARENT_IMAGE_NAME }}
3535
PARENT_IMAGE_TYPE: ${{ vars.PARENT_IMAGE_TYPE }}
3636
DOCKERFILE: ${{ vars.DOCKERFILE }}
37+
HEAD_REF: parent-image-updates
3738
strategy:
3839
matrix:
3940
include: ${{ fromJson(needs.pi-matrix.outputs.include) }}
@@ -51,11 +52,10 @@ jobs:
5152
run: |
5253
RELEASE_IMAGE="${{ env.DOCKERHUB_CONTAINER_REGISTRY }}/${{ env.PARENT_IMAGE_NAME }}:${{ github.event.release.tag_name }}-${{ matrix.parent_image_type }}"
5354
BASE_REF="dev"
54-
HEAD_REF="parent-images"
5555
PR_TITLE="ci(pi): $RELEASE_IMAGE"
5656
57-
git branch -D "$HEAD_REF" || true
58-
git checkout -b "$HEAD_REF"
57+
git checkout "${{ env.HEAD_REF }}" || git checkout -b "${{ env.HEAD_REF }}"
58+
git push origin "${{ env.HEAD_REF }}" && git pull origin "${{ env.HEAD_REF }}"
5959
6060
bash cicd-deployment-scripts/pi/edit_dockerfile.sh \
6161
-i ${{ env.PARENT_IMAGE_NAME }} \
@@ -69,12 +69,12 @@ jobs:
6969
7070
git add ${{ env.DOCKERFILE }}
7171
git commit -m "$PR_TITLE" || true
72-
git push --force origin "$HEAD_REF"
72+
git push --force origin "${{ env.HEAD_REF }}"
7373
echo "::notice::${{ matrix.app }} updated to $RELEASE_IMAGE"
7474
7575
bash cicd-deployment-scripts/pi/pr_create.sh \
7676
-b "$BASE_REF" \
77-
-h "$HEAD_REF" \
77+
-h "${{ env.HEAD_REF }}" \
7878
-t "$PR_TITLE" \
7979
-o ${{ github.repository_owner }} \
8080
-r ${{ github.event.repository.name }} \

0 commit comments

Comments
 (0)