-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (84 loc) · 2.51 KB
/
prune-container-images.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
79
80
81
82
83
84
85
86
87
88
name: "Prune Container Images"
on:
workflow_call:
inputs:
prune-untagged:
description: "Prune all untagged images"
required: false
type: boolean
default: false
tags-to-keep:
description: "Tags to keep from being pruned"
required: false
type: string
default: |
main
master
latest
nightly
develop
tags-to-keep-regex:
description: "Tags to keep from being pruned (regex)"
required: false
type: string
default: |
^release(\d+)
^v(\d+).(\d+).(\d+)
tags-to-prune-regex:
description: "Tags to prune (regex)"
required: false
type: string
default: .*
dry-run:
description: "Dry run"
required: false
type: boolean
default: true
keep-younger-than:
description: "Keep tags younger than X days"
required: false
type: number
default: 14
keep-last:
description: "Keep the last X tags"
required: false
type: string
default: 10
package-name:
description: "Name of the package"
required: false
type: string
runners:
description: "Runner labels to use"
required: false
type: string
default: "['ubuntu-latest']"
secrets:
prune-token:
description: "Secret needed for GHCR access"
required: true
jobs:
prune-container-images:
runs-on: ${{ fromJson(inputs.runners)}}
steps:
- name: Prune untagged container images
uses: vlaurin/[email protected]
if: ${{ inputs.prune-untagged }}
with:
token: ${{ secrets.prune-token }}
organization: ${{ github.repository_owner }}
container: ${{ inputs.package-name }}
dry-run: ${{ inputs.dry-run }}
prune-untagged: ${{ inputs.prune-untagged }}
- name: Prune tagged container images
uses: vlaurin/[email protected]
with:
token: ${{ secrets.prune-token }}
organization: ${{ github.repository_owner }}
container: ${{ inputs.package-name }}
dry-run: ${{ inputs.dry-run }}
keep-younger-than: ${{ inputs.keep-younger-than }}
keep-last: ${{ inputs.keep-last}}
keep-tags: ${{ inputs.tags-to-keep }}
keep-tags-regexes: ${{ inputs.tags-to-keep-regex}}
prune-tags-regexes: ${{ inputs.tags-to-prune-regex}}