@@ -80,15 +80,19 @@ jobs:
8080 exit 1
8181 fi
8282
83+ BUILD_SKIPPED=$(jq -r '.build_skipped // "false"' /tmp/pr-metadata/pr-info.json)
84+
8385 echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
8486 echo "commit_sha=${COMMIT_SHA}" >> $GITHUB_OUTPUT
8587 echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
8688 echo "primary_tag=${PRIMARY_TAG}" >> $GITHUB_OUTPUT
8789 echo "all_tags=${ALL_TAGS}" >> $GITHUB_OUTPUT
88-
90+ echo "build_skipped=${BUILD_SKIPPED}" >> $GITHUB_OUTPUT
91+
8992 echo "PR Number: $PR_NUMBER"
9093 echo "Commit SHA: $COMMIT_SHA"
9194 echo "Primary Tag: $PRIMARY_TAG"
95+ echo "Build Skipped: $BUILD_SKIPPED"
9296
9397 - name : Upload PR metadata for E2E tests
9498 uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
99103 if-no-files-found : error
100104
101105 - name : Download amd64 container artifact
106+ if : steps.pr-info.outputs.build_skipped != 'true'
102107 uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
103108 with :
104109 name : container-image-pr-${{ steps.pr-info.outputs.pr_number }}-amd64
@@ -107,6 +112,7 @@ jobs:
107112 github-token : ${{ secrets.GITHUB_TOKEN }}
108113
109114 - name : Download arm64 container artifact
115+ if : steps.pr-info.outputs.build_skipped != 'true'
110116 uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
111117 with :
112118 name : container-image-pr-${{ steps.pr-info.outputs.pr_number }}-arm64
@@ -115,18 +121,19 @@ jobs:
115121 github-token : ${{ secrets.GITHUB_TOKEN }}
116122
117123 - name : Set up Docker Buildx
124+ if : steps.pr-info.outputs.build_skipped != 'true'
118125 uses : docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
119126
120127 - name : Login to Quay
121- if : env.HAS_QUAY_AUTH == 'true'
128+ if : steps.pr-info.outputs.build_skipped != 'true' && env.HAS_QUAY_AUTH == 'true'
122129 uses : docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
123130 with :
124131 registry : ${{ env.REGISTRY }}
125132 username : ${{ secrets.QUAY_USERNAME }}
126133 password : ${{ secrets.QUAY_TOKEN }}
127134
128135 - name : Load, push images and create manifest
129- if : env.HAS_QUAY_AUTH == 'true'
136+ if : steps.pr-info.outputs.build_skipped != 'true' && env.HAS_QUAY_AUTH == 'true'
130137 id : push
131138 continue-on-error : true
132139 env :
@@ -201,7 +208,7 @@ jobs:
201208 echo "pushed_tags=${ALL_TAGS}" >> $GITHUB_OUTPUT
202209
203210 - name : Clean up architecture-specific tags
204- if : env.HAS_QUAY_AUTH == 'true' && steps.push.outcome == 'success' && env.QUAY_OAUTH_TOKEN != ''
211+ if : steps.pr-info.outputs.build_skipped != 'true' && env.HAS_QUAY_AUTH == 'true' && steps.push.outcome == 'success' && env.QUAY_OAUTH_TOKEN != ''
205212 env :
206213 ALL_TAGS : ${{ steps.pr-info.outputs.all_tags }}
207214 QUAY_OAUTH_TOKEN : ${{ secrets.QUAY_OAUTH_TOKEN }}
@@ -241,6 +248,7 @@ jobs:
241248 BUILD_RUN_ID : ${{ github.event.workflow_run.id }}
242249 PUBLISH_RUN_ID : ${{ github.run_id }}
243250 PUSH_OUTCOME : ${{ steps.push.outcome }}
251+ BUILD_SKIPPED : ${{ steps.pr-info.outputs.build_skipped }}
244252 with :
245253 script : |
246254 const prNumber = parseInt(process.env.PR_NUMBER);
@@ -251,61 +259,75 @@ jobs:
251259 const registry = process.env.REGISTRY;
252260 const image = process.env.REGISTRY_IMAGE;
253261 const pushOutcome = process.env.PUSH_OUTCOME;
254-
262+ const buildSkipped = process.env.BUILD_SKIPPED;
263+
255264 const prTag = `pr-${prNumber}`;
256265 const prShaTag = `pr-${prNumber}-${shortSha}`;
257-
266+
258267 let body;
259-
260- if (pushOutcome === 'success') {
268+
269+ if (buildSkipped === 'true') {
270+ body = `## Container Image Publish Skipped
271+
272+ The PR build was skipped (only non-build files were changed). No new image was published.
273+
274+ E2E tests will run against the existing image: \`${registry}/${image}:${prTag}\`
275+
276+ ### Traceability
277+
278+ - **Build:** [PR Build #${buildRunId}](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${buildRunId}) (skipped)
279+ - **Publish:** [PR Publish #${publishRunId}](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${publishRunId}) (skipped)
280+ - **Commit:** \`${shortSha}\`
281+ `;
282+ } else if (pushOutcome === 'success') {
261283 const expirationDate = new Date();
262284 expirationDate.setDate(expirationDate.getDate() + 14);
263285 const expirationStr = expirationDate.toLocaleDateString('en-US', {
264286 year: 'numeric',
265287 month: 'long',
266288 day: 'numeric'
267289 });
268-
290+
269291 body = `## Container Image Published
270-
292+
271293 Multi-platform container images are now available.
272-
294+
273295 | Tag | Image | Platforms |
274296 |-----|-------|-----------|
275297 | \`${prTag}\` | \`${registry}/${image}:${prTag}\` | linux/amd64, linux/arm64 |
276298 | \`${prShaTag}\` | \`${registry}/${image}:${prShaTag}\` | linux/amd64, linux/arm64 |
277-
299+
278300 **Expires:** ${expirationStr}
279-
301+
280302 ### Pull Commands
281-
303+
282304 \`\`\`bash
283305 # Multi-platform (auto-selects correct architecture)
284306 podman pull ${registry}/${image}:${prTag}
285-
307+
286308 # Or with specific commit SHA
287309 podman pull ${registry}/${image}:${prShaTag}
288310 \`\`\`
289-
311+
290312 ### Traceability
291-
313+
292314 - **Build:** [PR Build #${buildRunId}](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${buildRunId})
293315 - **Publish:** [PR Publish #${publishRunId}](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${publishRunId})
294316 - **Commit:** \`${shortSha}\`
295317 `;
296318 } else {
297319 body = `## Container Image Publish Failed
298-
320+
299321 The container image publish step failed. Please check the workflow logs for details.
300-
322+
301323 ### Traceability
302-
324+
303325 - **Build:** [PR Build #${buildRunId}](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${buildRunId})
304326 - **Publish:** [PR Publish #${publishRunId}](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${publishRunId}) (failed)
305327 - **Commit:** \`${shortSha}\`
306328 `;
307329 }
308-
330+
309331 await github.rest.issues.createComment({
310332 owner: context.repo.owner,
311333 repo: context.repo.repo,
@@ -345,6 +367,20 @@ jobs:
345367 echo "- **Triggered by:** [PR Build #${WORKFLOW_RUN_ID}](${SERVER_URL}/${REPOSITORY}/actions/runs/${WORKFLOW_RUN_ID})" >> $GITHUB_STEP_SUMMARY
346368 echo "- **Commit:** \`${SHORT_SHA}\`" >> $GITHUB_STEP_SUMMARY
347369
370+ - name : Build Skipped Summary
371+ if : steps.pr-info.outputs.build_skipped == 'true'
372+ env :
373+ PR_NUMBER : ${{ steps.pr-info.outputs.pr_number }}
374+ SHORT_SHA : ${{ steps.pr-info.outputs.short_sha }}
375+ run : |
376+ echo "## PR Image Publish Skipped (Build Skipped)" >> $GITHUB_STEP_SUMMARY
377+ echo "" >> $GITHUB_STEP_SUMMARY
378+ echo "The PR build was skipped — only non-build files were changed." >> $GITHUB_STEP_SUMMARY
379+ echo "No new image was published. E2E tests will use the existing \`pr-${PR_NUMBER}\` image." >> $GITHUB_STEP_SUMMARY
380+ echo "" >> $GITHUB_STEP_SUMMARY
381+ echo "- **PR Number**: #${PR_NUMBER}" >> $GITHUB_STEP_SUMMARY
382+ echo "- **Commit SHA**: \`${SHORT_SHA}\`" >> $GITHUB_STEP_SUMMARY
383+
348384 - name : No Auth Summary
349385 if : env.HAS_QUAY_AUTH != 'true'
350386 env :
@@ -359,7 +395,7 @@ jobs:
359395 echo "- **Commit SHA**: \`${SHORT_SHA}\`" >> $GITHUB_STEP_SUMMARY
360396
361397 - name : Publish Failed Summary
362- if : env.HAS_QUAY_AUTH == 'true' && steps.push.outcome != 'success'
398+ if : steps.pr-info.outputs.build_skipped != 'true' && env.HAS_QUAY_AUTH == 'true' && steps.push.outcome != 'success'
363399 env :
364400 PR_NUMBER : ${{ steps.pr-info.outputs.pr_number }}
365401 SHORT_SHA : ${{ steps.pr-info.outputs.short_sha }}
@@ -380,7 +416,7 @@ jobs:
380416 echo "- **Commit:** \`${SHORT_SHA}\`" >> $GITHUB_STEP_SUMMARY
381417
382418 - name : Fail workflow if publish failed
383- if : env.HAS_QUAY_AUTH == 'true' && steps.push.outcome != 'success'
419+ if : steps.pr-info.outputs.build_skipped != 'true' && env.HAS_QUAY_AUTH == 'true' && steps.push.outcome != 'success'
384420 run : |
385421 echo "Publish step failed. Failing workflow."
386422 exit 1
0 commit comments