Skip to content

feat(ci): keep only latest PR preview image to reduce storage#1690

Open
ArtieReus wants to merge 5 commits into
mainfrom
artie-keep-just-last-image-preview
Open

feat(ci): keep only latest PR preview image to reduce storage#1690
ArtieReus wants to merge 5 commits into
mainfrom
artie-keep-just-last-image-preview

Conversation

@ArtieReus
Copy link
Copy Markdown
Collaborator

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

  • Added cleanup-old-images job that runs after successful image builds
  • Added image-built and pr-version outputs to build-and-push job for cleanup coordination
  • Configured cleanup to use shared GHCR cleanup workflow with exclude-tags to preserve the newly built image
  • Updated workflow header comments to reflect new cleanup step
  • Updated docs/greenhouse-pr-preview-workflow.md with new job documentation and flow diagram
  • Added retention policy documentation for Docker images
  • Removed unused assets/pr-preview/AppContent.tsx file

Related Issues

Screenshots (if applicable)

Screenshot 2026-05-13 at 12 48 38 Screenshot 2026-05-13 at 15 02 56

Testing Instructions

  1. Create a test PR and add the greenhouse-pr-build label
  2. Wait for the initial image to build successfully
  3. Push a new commit to the PR
  4. Verify that:
    • A new image with the new commit SHA is built and pushed
    • The cleanup-old-images job runs after the build
    • Only the latest image tag exists in GHCR (old image is deleted)
    • The preview deployment works as expected
  5. Close the PR and verify all remaining images are cleaned up

Alternative: Review the workflow logic and job conditions in the changed YAML file.

Checklist

  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works. (N/A - workflow change, tested via actual PR workflow runs)
  • New and existing unit tests pass locally with my changes. (N/A - no code changes)
  • I have made corresponding changes to the documentation (if applicable).
  • My changes generate no new warnings or errors.
  • I have created a changeset for my changes. (N/A - workflow file, not a package change)

PR Manifesto

Review the PR Manifesto for best practises.

ArtieReus added 2 commits May 13, 2026 14:57
Signed-off-by: Arturo Reuschenbach Puncernau <reuschenbach@gmail.com>
Signed-off-by: Arturo Reuschenbach Puncernau <reuschenbach@gmail.com>
Copilot AI review requested due to automatic review settings May 13, 2026 13:03
@ArtieReus ArtieReus requested a review from a team as a code owner May 13, 2026 13:03
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 13, 2026

⚠️ No Changeset found

Latest commit: 7a78e1e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ArtieReus ArtieReus self-assigned this May 13, 2026
@ArtieReus ArtieReus added the greenhouse-pr-build Set this label to create a preview image which will automatically set the `greenhouse-pr-preview` label May 13, 2026
@github-actions github-actions Bot added the greenhouse-pr-preview THIS LABEL IS SET AUTOMATICALLY. label May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-images reusable 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-push job adds the greenhouse-pr-preview label before this dependent job runs, and that label change triggers a new workflow run in the same concurrency group with cancel-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'

Comment thread docs/greenhouse-pr-preview-workflow.md Outdated
Comment thread .github/workflows/build-push-greenhouse-pr-preview.yaml Outdated
Signed-off-by: Arturo Reuschenbach Puncernau <reuschenbach@gmail.com>
@github-actions github-actions Bot added greenhouse-pr-preview THIS LABEL IS SET AUTOMATICALLY. and removed greenhouse-pr-preview THIS LABEL IS SET AUTOMATICALLY. labels May 13, 2026
@github-actions github-actions Bot added greenhouse-pr-preview THIS LABEL IS SET AUTOMATICALLY. and removed greenhouse-pr-preview THIS LABEL IS SET AUTOMATICALLY. labels May 14, 2026
@github-actions github-actions Bot added greenhouse-pr-preview THIS LABEL IS SET AUTOMATICALLY. and removed greenhouse-pr-preview THIS LABEL IS SET AUTOMATICALLY. labels May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

greenhouse-pr-build Set this label to create a preview image which will automatically set the `greenhouse-pr-preview` greenhouse-pr-preview THIS LABEL IS SET AUTOMATICALLY.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug](ci): PR preview deep links fail with blank page and MIME type error

5 participants