ci: add path-based filtering and rollup for container image builds#833
ci: add path-based filtering and rollup for container image builds#833mangelajo wants to merge 1 commit into
Conversation
Add a changes job that detects which Containerfile dependencies were modified, so the merge queue only builds images that actually need rebuilding. Each matrix entry has a 'filter' key mapping to a path filter output. Behavior by event: - push to main/tags/release: always build all images - workflow_dispatch: always build all images - pull_request: only build when labeled (existing behavior preserved) - merge_group: only build images whose dependencies changed Add an 'image-builds' rollup job that can be used as a single required status check in branch protection, similar to 'pytest' and 'e2e'.
📝 WalkthroughWalkthroughThe ChangesImage Build Gating and Failure Reporting
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/build-images.yaml:
- Around line 32-34: The actions/checkout step in the changes job is persisting
credentials by default, which unnecessarily exposes authentication tokens since
this job only performs local path filtering with dorny/paths-filter that
requires no authenticated operations. Add persist-credentials: false to the with
block of the actions/checkout step to disable credential persistence and reduce
the attack surface by minimizing token exposure.
- Around line 21-31: The `changes` job lacks explicit GITHUB_TOKEN permission
declarations, relying on default permissions which violates least privilege
security practices. Add an explicit `permissions` field to the `changes` job
configuration to lock down token access. Set the permissions to either read-only
access (if the job requires reading repository data) or empty permissions (if
the job requires no token access), depending on what the filter step actually
needs. Repeat this same fix for the `image-builds` job mentioned at line 359.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9f5eb2f8-7655-4e8c-8651-703829ede23a
📒 Files selected for processing (1)
.github/workflows/build-images.yaml
Container ImagesThe following container images have been built for this PR:
Images expire after 7 days. |
| - 'python/Containerfile.utils' | ||
| python-dev: | ||
| - 'python/.devfile/Containerfile' | ||
| - '.py-version' |
Problem
The
build-imagesworkflow builds all 8 container images on every merge queue run, even when most images' dependencies haven't changed. There's also no rollup job for use as a required status check.Changes
Path-based filtering per image
Added a
changesjob usingdorny/paths-filterthat detects which Containerfile dependencies were modified. Each matrix entry now has afilterkey mapping to a path filter:controllercontroller/{Containerfile,go.mod,go.sum,cmd/,api/,internal/}operatorcontroller/{Containerfile.operator,go.*,api/,internal/,deploy/operator/}operator-bundlecontroller/deploy/operator/{Containerfile.bundle,bundle/}microshiftcontroller/deploy/microshift-bootc/,controller/deploy/operator/dist/pythonpython/python-utilspython/Containerfile.utilspython-devpython/.devfile/Containerfile,.py-versionBehavior by event
Rollup job
Added an
image-buildsrollup job that can be set as a single required status check in branch protection. It passes when all builds succeed or are intentionally skipped (no changes), and fails on actual failures or cancellations.Required status check
Add
image-buildsto branch protection required checks. This single check covers all container image builds regardless of how many were skipped vs built.