Skip to content

Commit e97269a

Browse files
committed
feat: add image docker cleanup workflows
SE-6574 Signed-off-by: Gabor Boros <gabor@opencraft.com>
1 parent aae08b6 commit e97269a

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Cleanup Container Packages
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
RUNNER_WORKFLOW_LABEL:
7+
description: "The label of the runner workflow to run"
8+
required: false
9+
type: string
10+
default: "ubuntu-latest"
11+
MIN_VERSIONS_TO_KEEP:
12+
description: "Number of newest package versions to retain per GHCR package"
13+
required: false
14+
type: number
15+
default: 5
16+
PACKAGE_SUFFIXES_JSON:
17+
description: 'JSON array of package name suffixes (GHCR package is "<repo>/<suffix>")'
18+
required: false
19+
type: string
20+
default: '["openedx","mfe"]'
21+
DELETE_ONLY_UNTAGGED_VERSIONS:
22+
description: "If true, only untagged container versions are eligible for deletion"
23+
required: false
24+
type: boolean
25+
default: false
26+
27+
jobs:
28+
cleanup:
29+
name: Cleanup ${{ matrix.package_suffix }}
30+
runs-on: ${{ inputs.RUNNER_WORKFLOW_LABEL }}
31+
permissions:
32+
contents: read
33+
packages: write
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
package_suffix: ${{ fromJSON(inputs.PACKAGE_SUFFIXES_JSON) }}
38+
steps:
39+
- name: Cleanup registry
40+
uses: actions/delete-package-versions@v5
41+
with:
42+
package-name: ${{ github.event.repository.name }}/${{ matrix.package_suffix }}
43+
package-type: container
44+
min-versions-to-keep: ${{ inputs.MIN_VERSIONS_TO_KEEP }}
45+
delete-only-untagged-versions: ${{ inputs.DELETE_ONLY_UNTAGGED_VERSIONS }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Cleanup Container Packages
2+
3+
on:
4+
schedule:
5+
- cron: "0 3 * * 0" # Sunday 03:00 UTC
6+
workflow_dispatch:
7+
8+
jobs:
9+
cleanup-container-packages:
10+
name: Cleanup container packages
11+
permissions:
12+
contents: read
13+
packages: write
14+
uses: open-craft/launchpad-cluster-template/.github/workflows/cleanup-container-packages.yml@main
15+
with:
16+
RUNNER_WORKFLOW_LABEL: "{{ cookiecutter.runner_workflow_label }}"
17+
MIN_VERSIONS_TO_KEEP: 5
18+
PACKAGE_SUFFIXES_JSON: '["openedx","mfe"]'
19+
DELETE_ONLY_UNTAGGED_VERSIONS: false

0 commit comments

Comments
 (0)