ci: skip the image build when a change cannot affect the image - #4
Conversation
Every PR rebuilt and pushed the devcontainer image regardless of what it touched — the App-token PR is doing exactly that right now for a change confined to release workflows. A cheap `changes` job classifies the diff and the expensive steps are guarded on it. The jobs themselves still run and still post their checks: skipping a job leaves its required check unreported, which is the failure this repo spent today stuck in. ci-gate now also gates on `changes`, so a failure there blocks rather than silently skipping the build. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR optimizes the CI workflow by detecting whether a PR’s file changes can impact the devcontainer image, and only running the expensive image build/push steps when necessary—while still ensuring required checks are always reported via ci-gate.
Changes:
- Add a
changesjob that classifies whether the devcontainer image could be affected (based on a base..head diff). - Guard the checkout/login/build/push/comment steps in
buildbehindneeds.changes.outputs.image == 'true'so thebuildjob still reports a check but avoids expensive work when irrelevant. - Update
ci-gateto depend on bothchangesandbuild, and to fail unless all required jobs concludesuccess.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: Comment image tag on PR | ||
| # No image was built, so there is no tag to advertise. | ||
| if: needs.changes.outputs.image == 'true' | ||
| uses: actions/github-script@v7 |
Pushing a follow-up commit to an open PR left the previous run building and pushing the image to completion, so a branch could have two full image pushes to the same GHCR package in flight at once. Only the newest commit's result gates the merge, so the older run is cancelled. Scoped per PR, so runs on different PRs never cancel each other. Matches plcc-ng-devcontainer. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
🐳 PR image built: To test manually, update |
1 similar comment
|
🐳 PR image built: To test manually, update |
|
🎉 This PR is included in version 1.1.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Every PR rebuilt and pushed the devcontainer image regardless of what it touched — the App-token PR is doing exactly that right now for a change confined to release workflows.
A cheap
changesjob classifies the diff and the expensive steps are guarded on it. The jobs themselves still run and still post their checks: skipping a job leaves its required check unreported, which is the failure this repo spent today stuck in.ci-gate now also gates on
changes, so a failure there blocks rather than silently skipping the build.