-
-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (45 loc) · 1.96 KB
/
cleanup-registry.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
name: cleanup registry
on:
schedule:
- cron: "0 0 * * 0" # Run weekly at midnight on Sunday
workflow_dispatch: # Allow manual triggers
jobs:
cleanup:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DO_REGISTRY_KEY }}
- name: Clean up API images
run: |
# Get all tags except 'latest' and 'buildcache', sort by creation date, and keep only the newest 3
TAGS_TO_DELETE=$(doctl registry repository list-tags ${{ vars.API_IMAGE }} --format Tag --no-header | grep -v -E '^(latest|buildcache)$' | sort -r | tail -n +4)
# Delete old tags if they exist
if [ ! -z "$TAGS_TO_DELETE" ]; then
echo "Deleting old API tags: $TAGS_TO_DELETE"
for TAG in $TAGS_TO_DELETE; do
doctl registry repository delete-tag ${{ vars.API_IMAGE }} $TAG --force
done
fi
- name: Clean up Queue images
run: |
TAGS_TO_DELETE=$(doctl registry repository list-tags ${{ vars.QUEUE_IMAGE }} --format Tag --no-header | grep -v -E '^(latest|buildcache)$' | sort -r | tail -n +4)
if [ ! -z "$TAGS_TO_DELETE" ]; then
echo "Deleting old Queue tags: $TAGS_TO_DELETE"
for TAG in $TAGS_TO_DELETE; do
doctl registry repository delete-tag ${{ vars.QUEUE_IMAGE }} $TAG --force
done
fi
- name: Clean up UI images
run: |
TAGS_TO_DELETE=$(doctl registry repository list-tags ${{ vars.UI_IMAGE }} --format Tag --no-header | grep -v -E '^(latest|buildcache)$' | sort -r | tail -n +4)
if [ ! -z "$TAGS_TO_DELETE" ]; then
echo "Deleting old UI tags: $TAGS_TO_DELETE"
for TAG in $TAGS_TO_DELETE; do
doctl registry repository delete-tag ${{ vars.UI_IMAGE }} $TAG --force
done
fi