generated from giantswarm/python-app-template
-
Notifications
You must be signed in to change notification settings - Fork 1
123 lines (110 loc) · 4.18 KB
/
cleanup.yaml
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
113
114
115
116
117
118
119
120
121
122
123
name: App Catalog Cleanup
on:
workflow_call:
inputs:
app-regexp:
description: "Regexp of app names the cleanup will apply to"
default: ".*"
required: false
type: string
keep-since:
description: "A full date-time. Catalog entries older than this timestamp will be removed"
required: false
type: string
delete-before:
description: "A time delta (like '3 days' or '4 weeks') to keep catalog entries. Catalog entries older will be removed"
required: false
type: string
limit-number:
description: "Most recent versions to keep in the catalog"
required: false
type: string
debug:
description: "Enable debug mode"
default: true
required: false
type: boolean
dry-run:
description: "Enable dry-run mode"
default: true
required: false
type: boolean
jobs:
cleanup:
name: Run the ACC tool
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Ignore index.yaml.back file
run: echo "index.yaml.back" >> .git/info/exclude
- name: Check for dry-run
id: dry-run
run: |
if [ ${{ inputs.dry-run }} = true ]
then
echo "dry-run=--dry-run" >> $GITHUB_OUTPUT
else
echo "dry-run=" >> $GITHUB_OUTPUT
fi
- name: Check for debug
id: debug
run: |
if [ ${{ inputs.debug }} = true ]
then
echo "debug=--debug" >> $GITHUB_OUTPUT
else
echo "debug=" >> $GITHUB_OUTPUT
fi
- name: Conclude condition
id: condition
run: |
if [[ ! -z "${{ inputs.keep-since }}" ]]
then
echo "condition=--keep-since \"${{ inputs.keep-since }}\"" >> $GITHUB_OUTPUT
elif [[ ! -z "${{ inputs.delete-before }}" ]]
then
echo "condition=--delete-before \"${{ inputs.delete-before }}\"" >> $GITHUB_OUTPUT
elif [[ ! -z "${{ inputs.limit-number }}" ]]
then
echo "condition=--limit-number \"${{ inputs.limit-number }}\"" >> $GITHUB_OUTPUT
else
echo "condition=" >> $GITHUB_OUTPUT
fi
- name: Execute ACC tool
uses: docker://gsoci.azurecr.io/giantswarm/app-catalog-cleanup-tool:0.2.7
with:
args: -a "${{ inputs.app-regexp }}" ${{ steps.condition.outputs.condition }} ${{ steps.dry-run.outputs.dry-run }} .
- name: Setup Helm
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
with:
version: v3.14.0
- name: Recreate the repository index.yaml
run: |
mkdir /tmp/build.tmp
helm repo index --url "https://giantswarm.github.io/$(echo -n ${{ env.GITHUB_REPOSITORY }} | cut -d '/' -f2)" --merge index.yaml /tmp/build.tmp
sudo cp /tmp/build.tmp/index.yaml .
- name: Create Pull Request
id: pull-request
if: ${{ ! inputs.dry-run }}
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v7.0.6
with:
token: ${{ github.token }}
title: Periodic App Catalog Cleanup
commit-message: Periodic App Catalog Cleanup
branch: cleanup/acct-run-${{ github.run_id }}
delete-branch: true
draft: false
body: |
Periodic cleanup.
- Application Regexp: `${{ inputs.app-regexp }}`
- Cleanup Condition: `${{ steps.condition.outputs.condition }}`
- Created By: [ACCT Github Workflow][1]
[1]: https://raw.githubusercontent.com/giantswarm/app-catalog-cleanup-tool/feature/cleanup-workflow/.github/workflows/cleanup.yaml
- name: Merge Pull Request
if: steps.pull-request.outputs.pull-request-operation == 'created'
uses: juliangruber/merge-pull-request-action@9234b8714dda9a08f3d1df5b2a6a3abd7b695353 # v1.3.1
with:
github-token: ${{ github.token }}
number: ${{ steps.pull-request.outputs.pull-request-number }}
method: squash