feat(ci): keep only latest PR preview image to reduce storage#1690
feat(ci): keep only latest PR preview image to reduce storage#1690ArtieReus wants to merge 5 commits into
Conversation
Signed-off-by: Arturo Reuschenbach Puncernau <reuschenbach@gmail.com>
Signed-off-by: Arturo Reuschenbach Puncernau <reuschenbach@gmail.com>
|
There was a problem hiding this comment.
Pull request overview
This PR updates the Greenhouse PR preview workflow to reduce GHCR storage by keeping only the latest preview image per PR, and documents the intended cleanup behavior.
Changes:
- Adds a
cleanup-old-imagesreusable workflow job after PR preview image builds. - Exposes build outputs used to preserve the newly built image during cleanup.
- Updates Greenhouse PR preview documentation and removes the unused
assets/pr-preview/AppContent.tsx.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
.github/workflows/build-push-greenhouse-pr-preview.yaml |
Adds build outputs and a cleanup job for old PR preview images. |
docs/greenhouse-pr-preview-workflow.md |
Documents the new image-retention behavior and cleanup job. |
assets/pr-preview/AppContent.tsx |
Removes an unused PR preview component file. |
Comments suppressed due to low confidence (1)
.github/workflows/build-push-greenhouse-pr-preview.yaml:179
- This cleanup job is likely to be cancelled before it can delete anything. The
build-and-pushjob adds thegreenhouse-pr-previewlabel before this dependent job runs, and that label change triggers a new workflow run in the same concurrency group withcancel-in-progress: true, which cancels the still-running/pending cleanup job. Move the cleanup before the label-add step or otherwise prevent the self-trigger from cancelling the cleanup run.
cleanup-old-images:
name: Cleanup Old PR Images
needs: build-and-push
if: needs.build-and-push.outputs.image-built == 'true'
Signed-off-by: Arturo Reuschenbach Puncernau <reuschenbach@gmail.com>
Summary
Optimizes GHCR storage usage by automatically deleting old PR preview Docker images after each new build. Only the most recent image per PR is retained during the PR lifecycle, significantly reducing storage costs while maintaining full preview functionality.
Also removes unused AppContent.tsx file from the assets/pr-preview directory.
Changes Made
cleanup-old-imagesjob that runs after successful image buildsimage-builtandpr-versionoutputs tobuild-and-pushjob for cleanup coordinationexclude-tagsto preserve the newly built imagedocs/greenhouse-pr-preview-workflow.mdwith new job documentation and flow diagramassets/pr-preview/AppContent.tsxfileRelated Issues
Screenshots (if applicable)
Testing Instructions
greenhouse-pr-buildlabelcleanup-old-imagesjob runs after the buildAlternative: Review the workflow logic and job conditions in the changed YAML file.
Checklist
PR Manifesto
Review the PR Manifesto for best practises.