Skip to content

cleanup old docker images on registry#180

Merged
mitch10593 merged 2 commits intomainfrom
feature/177-auto-cleanup-docker-images-docker-untagged-on-ghcr
Mar 12, 2026
Merged

cleanup old docker images on registry#180
mitch10593 merged 2 commits intomainfrom
feature/177-auto-cleanup-docker-images-docker-untagged-on-ghcr

Conversation

@mitch10593
Copy link
Copy Markdown
Contributor

@mitch10593 mitch10593 commented Mar 12, 2026

Summary by Sourcery

Add scheduled GitHub Actions workflow to regularly clean up untagged Docker images from the container registry and document the change in the changelog.

Bug Fixes:

  • Ensure old untagged Docker images are automatically cleaned up from the registry to prevent accumulation of unused images.

CI:

  • Introduce a scheduled GitHub Actions workflow that deletes untagged container package versions while keeping a minimum number of recent images.

@mitch10593 mitch10593 added this to the 2.1 milestone Mar 12, 2026
@mitch10593 mitch10593 self-assigned this Mar 12, 2026
@mitch10593 mitch10593 linked an issue Mar 12, 2026 that may be closed by this pull request
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Mar 12, 2026

Reviewer's Guide

Adds a scheduled GitHub Actions workflow to automatically delete untagged container images from GHCR for backend and frontend packages, and documents the change in the changelog.

Flow diagram for scheduled GHCR untagged image cleanup job

flowchart TD
  A[Start scheduled or manual workflow] --> B[Initialize job cleanup on ubuntu-latest]
  B --> C[Set permissions: packages delete]
  C --> D[Create matrix over packages
website-2026-backend
website-2026-frontend]
  D --> E[For each package: run actions/delete-package-versions@v5]
  E --> F[Configure action
package-name = matrix.package
package-type = container
delete-only-untagged-versions = true
min-versions-to-keep = 5]
  F --> G[GHCR deletes matching untagged container images]
  G --> H[End]
Loading

File-Level Changes

Change Details Files
Introduce scheduled GitHub Actions workflow to clean up untagged Docker images in GHCR for key services.
  • Create a new GitHub Actions workflow triggered weekly via cron and manually via workflow_dispatch
  • Define a single cleanup job running on ubuntu-latest with package delete permissions
  • Use a matrix strategy to target backend and frontend container packages
  • Configure the delete-package-versions action to delete only untagged container images while keeping at least five versions
.github/workflows/cleanup-ghcr.yml
Document the Docker image cleanup fix in the changelog.
  • Add a FIXED entry describing the registry Docker image cleanup under version 2.1.1
CHANGELOG.md

Assessment against linked issues

Issue Objective Addressed Explanation
#177 Add a GitHub Actions workflow .github/workflows/cleanup-ghcr.yml that runs on a schedule every Sunday at 03:00 UTC and can also be triggered manually via workflow_dispatch.
#177 In that workflow, delete only untagged Docker container images for the website-2026-backend and website-2026-frontend packages on GHCR, keeping a minimum of 5 untagged versions.
#177 Use the official actions/delete-package-versions@v5 action to perform the cleanup.

Possibly linked issues

  • #auto cleanup docker images Docker untagged on GHCR: PR adds cleanup-ghcr workflow with schedule, targets, retention, and action exactly as requested in the issue.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/cleanup-ghcr.yml" line_range="11-12" />
<code_context>
+jobs:
+  cleanup:
+    runs-on: ubuntu-latest
+    permissions:
+      packages: delete
+    strategy:
+      matrix:
</code_context>
<issue_to_address>
**issue (bug_risk):** The `permissions.packages` value should be `write` rather than `delete`, otherwise the workflow may not have the right permissions.

`packages` permissions only support `read` or `write`; `delete` is not valid. `actions/delete-package-versions` requires `packages: write` to delete versions, so this job will likely fail at runtime. Please change this block to:

```yaml
jobs:
  cleanup:
    permissions:
      packages: write
```

(You can keep the permissions scoped at the job level as you have it.)
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@mitch10593 mitch10593 merged commit 8e21db6 into main Mar 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auto cleanup docker images Docker untagged on GHCR

1 participant