-
Notifications
You must be signed in to change notification settings - Fork 14
89 lines (81 loc) · 2.87 KB
/
prune-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
89
name: Prune Images
run-name: Pruning all but the most recent ${{ inputs.minTags }} tags prior to what is deployed in ${{ inputs.environment }}
on:
workflow_dispatch:
inputs:
environment:
type: choice
description: "Environment"
required: true
options:
- dev
- test
- prod
default: "test"
applications:
description: "Comma seperated list of application Image Streams to prune"
required: true
default: "web-sims, api-sims, queue-consumers-sims, workers-sims"
ocjobs:
description: "Comma seperated list of job Image Streams to prune"
required: true
default: "db.migrations"
prefix:
description: "Branch prefix to restrict pruning to"
required: false
default: "main"
minTags:
description: "Minimum number of Tags to keep"
required: false
default: "10"
schedule:
- cron: "0 14 * * *" # Runs at 6 AM Pacific every day
jobs:
prune-images:
runs-on: ubuntu-latest
steps:
- name: Set default inputs when triggered via schedule
run: |
echo "ENVIRONMENT=${{ inputs.environment || 'test' }}" >> $GITHUB_ENV
echo "APPLICATIONS=${{ inputs.applications || 'web-sims, api-sims, queue-consumers-sims, workers-sims' }}" >> $GITHUB_ENV
echo "OCJOBS=${{ inputs.ocjobs || 'db.migrations' }}" >> $GITHUB_ENV
echo "PREFIX=${{ inputs.prefix || 'main' }}" >> $GITHUB_ENV
echo "MIN_TAGS=${{ inputs.minTags || '10' }}" >> $GITHUB_ENV
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4"
- name: Print env
run: |
echo "Environment: ${ENVIRONMENT}"
echo "Applications: ${APPLICATIONS}"
echo "Jobs: ${OCJOBS}"
echo "Prefix: ${PREFIX}"
echo "Minimum Tags: ${MIN_TAGS}"
echo "OC CLI Version: $(oc version)"
- name: Checkout source code
uses: actions/checkout@v4
- name: Login to OpenShift
run: |
oc login --token=${{ secrets.SA_TOKEN }} --server=${{ vars.OPENSHIFT_CLUSTER_URL }}
- name: Prune DC Images
run: |
pushd devops/scripts
./pruneImages.sh \
--license_plate=${{ vars.OPENSHIFT_LICENSE_PLATE }} \
--env=${ENVIRONMENT} \
--apps="${APPLICATIONS}" \
--prefix=${PREFIX} \
--min_tags=${MIN_TAGS}
popd
- name: Prune Job Images
run: |
pushd devops/scripts
./pruneImages.sh \
--license_plate=${{ vars.OPENSHIFT_LICENSE_PLATE }} \
--env=${ENVIRONMENT} \
--apps="${OCJOBS}" \
--prefix=${PREFIX} \
--min_tags=${MIN_TAGS} \
--type=JOB
popd