Skip to content

Commit f930dd3

Browse files
committed
Make ghcr.io cleanup more robust
We need to ensure that we don't accidentally delete not-yet-tagged images created by other PR's jobs. Additionally, we enable `delete-untagged` for the job that deletes the PR tag after the PR gets closed.
1 parent bd5d491 commit f930dd3

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

.github/workflows/cleanup-pr-tag.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ jobs:
1919
tags: ${{ env.VERSION }}
2020
package: ${{ github.event.repository.name }}
2121
token: ${{ secrets.GITHUB_TOKEN }}
22+
# NOTE(sg): When we delete a tag, we need to explicitly enable
23+
# `delete-untagged` to also cleanup the now untagged images. Here,
24+
# we probably don't need to have an age guard, since this action
25+
# will almost certainly always run before other (renovate) PRs are
26+
# updated to the latest master branch.
27+
delete-untagged: true

.github/workflows/container-image.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ jobs:
244244
with:
245245
token: ${{ secrets.GITHUB_TOKEN }}
246246
package: ${{ github.event.repository.name }}
247+
# NOTE(sg): Only delete untagged images older than 5 minutes, so that
248+
# we don't delete not-yet-tagged images generated by other PR's jobs.
249+
older-than: 5 minutes
247250
validate: true
248251

249252
release:

0 commit comments

Comments
 (0)