@@ -164,19 +164,92 @@ jobs:
164164 env :
165165 GH_TOKEN : ${{ secrets.COMPONENT_ACCESS_TOKEN }}
166166 steps :
167+ - name : Merge PR in appcat repo
168+ run : |
169+ echo "✅ Merging appcat PR: https://github.com/$APPCAT_REPO/pull/${{ needs.check-conditions.outputs.pr-number }}"
170+ gh pr merge -R "$APPCAT_REPO" ${{ needs.check-conditions.outputs.pr-number }} --merge --delete-branch
171+ env :
172+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
173+
174+ - name : Get merge commit SHA from PR
175+ id : merge-commit
176+ run : |
177+ # Wait for merge to be reflected in API
178+ sleep 2
179+
180+ # Get the merge commit SHA directly from the PR
181+ MERGE_COMMIT_SHA=$(gh pr view ${{ needs.check-conditions.outputs.pr-number }} \
182+ -R "$APPCAT_REPO" \
183+ --json mergeCommit \
184+ --jq '.mergeCommit.oid')
185+
186+ # Verify we got the commit that contains our PR's changes
187+ LAST_PR_COMMIT="${{ needs.check-conditions.outputs.last-sha }}"
188+
189+ # Check if the merge commit has our last PR commit as a parent
190+ PARENTS=$(gh api repos/$APPCAT_REPO/commits/$MERGE_COMMIT_SHA --jq '[.parents[].sha] | join(" ")')
191+
192+ if ! echo "$PARENTS" | grep -q "$LAST_PR_COMMIT"; then
193+ echo "❌ Merge commit $MERGE_COMMIT_SHA does not contain PR commit $LAST_PR_COMMIT"
194+ echo "Parents: $PARENTS"
195+ exit 1
196+ fi
197+
198+ echo "🔧 Merge commit SHA: $MERGE_COMMIT_SHA (verified)"
199+ echo "sha=$MERGE_COMMIT_SHA" >> "$GITHUB_OUTPUT"
200+ env :
201+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
202+
203+ - name : Checkout appcat repository at merge commit
204+ uses : actions/checkout@v4
205+ with :
206+ repository : ${{ env.APPCAT_REPO }}
207+ ref : ${{ steps.merge-commit.outputs.sha }}
208+ token : ${{ secrets.GITHUB_TOKEN }}
209+
210+ - name : Determine Go version from go.mod
211+ run : echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
212+
213+ - uses : actions/setup-go@v5
214+ with :
215+ go-version : ${{ env.GO_VERSION }}
216+
217+ - name : Set up QEMU
218+ uses : docker/setup-qemu-action@v3
219+
220+ - name : Set up Docker Buildx
221+ uses : docker/setup-buildx-action@v3
222+
223+ - name : Login to GHCR
224+ uses : docker/login-action@v3
225+ with :
226+ registry : ghcr.io
227+ username : ${{ github.repository_owner }}
228+ password : ${{ secrets.GITHUB_TOKEN }}
229+
230+ - name : Build and push Docker image with merge commit SHA
231+ run : |
232+ echo "🐳 Building and pushing image with tag: ${{ steps.merge-commit.outputs.sha }}"
233+ make docker-push -e IMG_TAG=${{ steps.merge-commit.outputs.sha }} -e APP_NAME=${{ env.APP_NAME }}
234+
235+ - name : Build and push function package with merge commit SHA
236+ run : |
237+ echo "📦 Building and pushing function package with tag: ${{ steps.merge-commit.outputs.sha }}"
238+ make package-push -e IMG_TAG=${{ steps.merge-commit.outputs.sha }} -e APP_NAME=${{ env.APP_NAME }}
239+
167240 - name : Clone and patch component repo
168241 run : |
169242 COMPONENT_BRANCH="${{ needs.check-conditions.outputs.comp-feature-branch }}"
170- APPCAT_FR_COMMIT_SHA ="${{ needs.check-conditions .outputs.last- sha }}"
171- echo "🔧 Using commit: $APPCAT_FR_COMMIT_SHA "
243+ APPCAT_MERGE_COMMIT_SHA ="${{ steps.merge-commit .outputs.sha }}"
244+ echo "🔧 Using merge commit: $APPCAT_MERGE_COMMIT_SHA "
172245 echo "🔧 Cloning branch: $COMPONENT_BRANCH"
173246
174247 git clone https://x-access-token:$GH_TOKEN@github.com/"$COMPONENT_REPO".git
175248 cd component-appcat
176249 git checkout "$COMPONENT_BRANCH"
177250
178251 echo "🔧 Patching class/defaults.yml..."
179- yq e ".parameters.appcat.images.appcat.tag = \"$APPCAT_FR_COMMIT_SHA \"" class/defaults.yml \
252+ yq e ".parameters.appcat.images.appcat.tag = \"$APPCAT_MERGE_COMMIT_SHA \"" class/defaults.yml \
180253 | diff -B class/defaults.yml - \
181254 | patch class/defaults.yml - || echo "✅ No patch needed"
182255
@@ -189,7 +262,7 @@ jobs:
189262 if git diff --cached --quiet; then
190263 echo "✅ No changes to commit"
191264 else
192- git commit -m "Auto update from appcat PR https://github.com/${{ env.APPCAT_REPO }}/pull/${{ needs.check-conditions.outputs.pr-number }}, dependency $APPCAT_FR_COMMIT_SHA "
265+ git commit -m "Auto update from appcat PR https://github.com/${{ env.APPCAT_REPO }}/pull/${{ needs.check-conditions.outputs.pr-number }}, dependency $APPCAT_MERGE_COMMIT_SHA "
193266 git push origin "$COMPONENT_BRANCH"
194267 fi
195268
@@ -210,11 +283,6 @@ jobs:
210283 echo "✅ Merging component PR: ${{ needs.check-conditions.outputs.comp-url }}"
211284 gh pr merge -R "$COMPONENT_REPO" ${{ needs.check-conditions.outputs.comp-pr-number }} --merge --delete-branch
212285
213- - name : Merge PR in appcat repo
214- run : |
215- echo "✅ Merging appcat PR: https://github.com/$APPCAT_REPO/pull/${{ needs.check-conditions.outputs.pr-number }}"
216- gh pr merge -R "$APPCAT_REPO" ${{ needs.check-conditions.outputs.pr-number }} --merge --delete-branch
217-
218286 merge-hotfix :
219287 needs : check-conditions
220288 if : needs.check-conditions.outputs.base-branch == 'master' && needs.check-conditions.outputs.is-hotfix == 'true'
0 commit comments