Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dangling images from GHCR on schedule #941

Merged
merged 4 commits into from
Jan 8, 2022
Merged

Remove dangling images from GHCR on schedule #941

merged 4 commits into from
Jan 8, 2022

Conversation

ferferga
Copy link
Contributor

@ferferga ferferga commented Oct 31, 2021

Continuation of #940

Description

Contrary to DockerHub, GHCR keeps all the images uploaded, even those that are no longer associated to a tag. For example, updating the latest tags will keep the older image still around in the registry, but untagged.

This new workflow runs every day at 0:00 UTC and removes all the untagged images (aka dangling images)

Motivation and Context

  • There's no point in keeping untagged images at all but GitHub keeps everything by default. CI in general takes a lot of energy, storage and resources. Although those resources are free of charge for us, we don't need them and the environment will be happy with us 😊.

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Needed tokens

A secret ACCESS_TOKEN (a PAT for the org) must be added in order to remove dangling images, with the following permissions:

  • delete:packages
  • read:packages

If you prefer another name instead of ACCESS_TOKEN please let me know.

@TonyRL
Copy link

TonyRL commented Nov 1, 2021

FYI, both actions, GHCR Pruning and Container Retention Policy, support removing dangling images from GHCR.

@PromoFaux
Copy link
Member

I wonder if https://github.com/pi-hole/.github might be a better place for this (or similar using one of the abovementioned actions)

@ferferga
Copy link
Contributor Author

ferferga commented Dec 9, 2021

@PromoFaux The problem is that GH shuts down scheduled actions in a repository after 2 months with no activity, so unless that repo receives activity (not sure what GH considers activity), it won't work properly and will need constant maintenance from your side.

Here's an screenshot of the email I received in one repo where I had no activity:

Screenshot_20211209_195544_com.microsoft.office.outlook.jpg

@PromoFaux PromoFaux merged commit 0599a8a into pi-hole:dev Jan 8, 2022
PromoFaux added a commit that referenced this pull request Jan 8, 2022
edgd1er pushed a commit to edgd1er/docker-pi-hole that referenced this pull request Jan 9, 2022
* Remove dangling images from GHCR on schedule

Signed-off-by: Fernando Fernández <[email protected]>

* Commit .sh file as executable, so preparation is not needed at runtime

Signed-off-by: Fernando Fernández <[email protected]>

* Update .github/workflows/maintenance.yml

Signed-off-by: Adam Warner <[email protected]>

* Update .github/workflows/maintenance.yml

Signed-off-by: Fernando Fernández <[email protected]>

Co-authored-by: Adam Warner <[email protected]>
edgd1er pushed a commit to edgd1er/docker-pi-hole that referenced this pull request Jan 9, 2022
* Remove dangling images from GHCR on schedule

Signed-off-by: Fernando Fernández <[email protected]>

* Commit .sh file as executable, so preparation is not needed at runtime

Signed-off-by: Fernando Fernández <[email protected]>

* Update .github/workflows/maintenance.yml

Signed-off-by: Adam Warner <[email protected]>

* Update .github/workflows/maintenance.yml

Signed-off-by: Fernando Fernández <[email protected]>

Co-authored-by: Adam Warner <[email protected]>
edgd1er pushed a commit to edgd1er/docker-pi-hole that referenced this pull request Jan 9, 2022
* Remove dangling images from GHCR on schedule

Signed-off-by: Fernando Fernández <[email protected]>

* Commit .sh file as executable, so preparation is not needed at runtime

Signed-off-by: Fernando Fernández <[email protected]>

* Update .github/workflows/maintenance.yml

Signed-off-by: Adam Warner <[email protected]>

* Update .github/workflows/maintenance.yml

Signed-off-by: Fernando Fernández <[email protected]>

Co-authored-by: Adam Warner <[email protected]>
edgd1er pushed a commit to edgd1er/docker-pi-hole that referenced this pull request Jan 10, 2022
* Remove dangling images from GHCR on schedule

Signed-off-by: Fernando Fernández <[email protected]>

* Commit .sh file as executable, so preparation is not needed at runtime

Signed-off-by: Fernando Fernández <[email protected]>

* Update .github/workflows/maintenance.yml

Signed-off-by: Adam Warner <[email protected]>

* Update .github/workflows/maintenance.yml

Signed-off-by: Fernando Fernández <[email protected]>

Co-authored-by: Adam Warner <[email protected]>
edgd1er pushed a commit to edgd1er/docker-pi-hole that referenced this pull request Jan 10, 2022
* Remove dangling images from GHCR on schedule

Signed-off-by: Fernando Fernández <[email protected]>

* Commit .sh file as executable, so preparation is not needed at runtime

Signed-off-by: Fernando Fernández <[email protected]>

* Update .github/workflows/maintenance.yml

Signed-off-by: Adam Warner <[email protected]>

* Update .github/workflows/maintenance.yml

Signed-off-by: Fernando Fernández <[email protected]>

Co-authored-by: Adam Warner <[email protected]>
edgd1er pushed a commit to edgd1er/docker-pi-hole that referenced this pull request Jan 12, 2022
* Remove dangling images from GHCR on schedule

Signed-off-by: Fernando Fernández <[email protected]>

* Commit .sh file as executable, so preparation is not needed at runtime

Signed-off-by: Fernando Fernández <[email protected]>

* Update .github/workflows/maintenance.yml

Signed-off-by: Adam Warner <[email protected]>

* Update .github/workflows/maintenance.yml

Signed-off-by: Fernando Fernández <[email protected]>

Co-authored-by: Adam Warner <[email protected]>
edgd1er pushed a commit to edgd1er/docker-pi-hole that referenced this pull request Feb 4, 2022
* Remove dangling images from GHCR on schedule

Signed-off-by: Fernando Fernández <[email protected]>

* Commit .sh file as executable, so preparation is not needed at runtime

Signed-off-by: Fernando Fernández <[email protected]>

* Update .github/workflows/maintenance.yml

Signed-off-by: Adam Warner <[email protected]>

* Update .github/workflows/maintenance.yml

Signed-off-by: Fernando Fernández <[email protected]>

Co-authored-by: Adam Warner <[email protected]>
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.

3 participants