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

feat: added new workflow to prune old images #88

Merged
merged 16 commits into from
Jan 29, 2024
Merged
49 changes: 49 additions & 0 deletions .github/workflows/prune.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Prune GHCR

on:
schedule:
- cron: '0 0 * * *' # Runs workflow at '(minute) (hour) (day of the month) (month) (day of the week)'
JTaeuber marked this conversation as resolved.
Show resolved Hide resolved

permissions:
contents: write
packages: write
security-events: write

jobs:
prune_images:
name: Prune old sparrow images
runs-on: ubuntu-latest

permissions:
contents: write
packages: write
security-events: write
JTaeuber marked this conversation as resolved.
Show resolved Hide resolved

steps:

- name: Prune Images
uses: vlaurin/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
organization: caas-team
container: sparrow # Package name
JTaeuber marked this conversation as resolved.
Show resolved Hide resolved
dry-run: true # Dry-run first, then change to `false` or remove
JTaeuber marked this conversation as resolved.
Show resolved Hide resolved
keep-younger-than: 7 # days
keep-last: 2
JTaeuber marked this conversation as resolved.
Show resolved Hide resolved
prune-untagged: true
prune-tags-regexes: |
^commit-
SNAPSHOT-.*$
Copy link
Member

Choose a reason for hiding this comment

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

After the first prune we can remove this regex because our new images don't follow this naming pattern anymore.

Copy link
Member

Choose a reason for hiding this comment

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

The regex is unnecessary. We just want to remove old images, no matter what naming convention they used. Let's just remove it altogether.

Copy link
Member

@lvlcn-t lvlcn-t Jan 26, 2024

Choose a reason for hiding this comment

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

Then we'd also remove our stable release images because git tags != image tags

Copy link
Member

Choose a reason for hiding this comment

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

Totally right, my bad 😅


- name: Prune Charts
uses: vlaurin/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
organization: caas-team
container: charts/sparrow # Package name
dry-run: true # Dry-run first, then change to `false` or remove
keep-younger-than: 7 # days
keep-last: 2
prune-untagged: true
prune-tags-regexes: |
commit-.*$
Loading