-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
112 lines (109 loc) · 4.2 KB
/
action.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: 'Container Retention Policy (Forked from @snok)'
description: 'Create a retention policy for your GHCR hosted container images'
branding:
icon: "book"
color: "black"
inputs:
account-type:
description: "The type of account. Can be either 'org' or 'personal'."
required: true
org-name:
description: "The name of the organization. Only required if the account type is 'personal'."
default: ''
required: false
image-names:
description: 'Image name to delete. Supports passing several names as a comma-separated list.'
required: true
timestamp-to-use:
description: 'Whether to use updated_at or created_at timestamps. Defaults to updated_at.'
required: true
default: 'updated_at'
cut-off:
description: "The cut-off for which to delete images older than. For example '2 days ago UTC'. Timezone is required."
required: true
token:
description: 'Personal access token with read and delete scopes.'
required: true
untagged-only:
description: 'Restrict deletions to images without tags.'
required: false
default: 'false'
skip-tags:
description: "Restrict deletions to images without specific tags. Supports Unix-shell style wildcards"
required: false
keep-at-least:
description: 'How many images to keep no matter what. Defaults to 0 which means you might delete everything'
required: false
default: '0'
filter-tags:
description: "Comma-separated list of tags to consider for deletion. Supports Unix-shell style wildcards"
required: false
filter-include-untagged:
description: "Whether to consider untagged images for deletion."
required: false
default: 'true'
dry-run:
description: "Do not actually delete images. Print output showing what would have been deleted."
required: false
default: 'false'
token-type:
description: "The token type. Can be either 'pat' or 'github-token'. If 'github-token', then image-names must the package name of repository from where this action is invoked."
required: false
default: 'github-token'
outputs:
needs-github-assistance:
description: 'Comma-separated list of image names and tags, for image versions that are public and have more than 5000 downloads.'
value: ${{ steps.container-retention-policy.outputs.needs-github-assistance }}
deleted:
description: 'Comma-separated list of image names and tags, for image versions that were deleted during the run.'
value: ${{ steps.container-retention-policy.outputs.deleted }}
failed:
description: 'Comma-separated list of image names and tags, for image versions that we failed to delete during the run, for an unknown reason.'
value: ${{ steps.container-retention-policy.outputs.failed }}
runs:
using: 'composite'
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
shell: bash
run: |
pip --disable-pip-version-check install \
regex==2022.3.2 \
httpx \
dateparser \
pydantic
- name: Run Container Retention Policy
shell: bash
id: container-retention-policy
run: |
python ${{ github.action_path }}/main.py \
"$ACCOUNT_TYPE" \
"$ORG_NAME" \
"$IMAGE_NAMES" \
"$TIMESTAMP_TO_USE" \
"$CUT_OFF" \
"$TOKEN" \
"$UNTAGGED_ONLY" \
"$SKIP_TAGS" \
"$KEEP_AT_LEAST" \
"$FILTER_TAGS" \
"$FILTER_INCLUDE_UNTAGGED" \
"$DRY_RUN" \
"$TOKEN_TYPE"
env:
ACCOUNT_TYPE: "${{ inputs.account-type }}"
ORG_NAME: "${{ inputs.org-name }}"
IMAGE_NAMES: "${{ inputs.image-names }}"
TIMESTAMP_TO_USE: "${{ inputs.timestamp-to-use }}"
CUT_OFF: "${{ inputs.cut-off }}"
TOKEN: "${{ inputs.token }}"
UNTAGGED_ONLY: "${{ inputs.untagged-only }}"
SKIP_TAGS: "${{ inputs.skip-tags }}"
KEEP_AT_LEAST: "${{ inputs.keep-at-least }}"
FILTER_TAGS: "${{ inputs.filter-tags }}"
FILTER_INCLUDE_UNTAGGED: "${{ inputs.filter-include-untagged }}"
DRY_RUN: "${{ inputs.dry-run }}"
TOKEN_TYPE: "${{ inputs.token-type }}"