-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (68 loc) · 2.35 KB
/
prune.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Prune GHCR
on:
workflow_call:
inputs:
container:
description: |
The container image name to prune.
If this isn't set, the `prune_images` job will be skipped.
Example:
`ghcr.io/Codertocat/Hello-World`
-> `Hello-World`
type: string
required: false
chart:
description: |
The chart oci image name to prune.
If this isn't set, the `prune_charts` job will be skipped.
Example:
`ghcr.io/Codertocat/charts/Hello-World`
-> `charts/Hello-World`
type: string
required: false
keep-younger-than:
description: The number of days to keep images
type: number
required: false
default: 7
prune-untagged:
description: Whether to prune untagged images
type: boolean
required: false
default: true
permissions:
# Needed to delete images
packages: write
jobs:
prune_images:
name: Prune old images
runs-on: ubuntu-latest
if: ${{ inputs.container }} != null
steps:
- name: Prune Images
uses: vlaurin/action-ghcr-prune@v0.6.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
organization: ${{ github.repository_owner }}
container: ${{ inputs.container }}
keep-younger-than: ${{ inputs.keep-younger-than }}
prune-untagged: ${{ inputs.prune-untagged }}
# This is the default regex for semver tags (https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string)
keep-tags-regexes: ^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$
prune-tags-regexes: |
^commit-
prune_charts:
name: Prune old charts
runs-on: ubuntu-latest
if: ${{ inputs.chart }} != null
steps:
- name: Prune Charts
uses: vlaurin/action-ghcr-prune@v0.6.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
organization: ${{ github.repository_owner }}
container: ${{ inputs.chart }}
keep-younger-than: ${{ inputs.keep-younger-than }}
prune-untagged: ${{ inputs.prune-untagged }}
prune-tags-regexes: |
commit-.*$