Skip to content

Commit d690347

Browse files
perf: DEV registry delete bulk (#21)
* perf: add dc-registry-delete bulk * perf: make bulk workflow triggered by workflow_dispatch
1 parent 1cdb132 commit d690347

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

.github/workflows/dc_registry_delete.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jobs:
2929
environment: dev
3030
env:
3131
ENVIRONMENT_NAME: dev
32-
REGISTRY_HTTPS_USERNAME: "${{ secrets.REGISTRY_HTTPS_USERNAME }}"
3332
DEV_CONTAINER_REGISTRY: ${{ vars.DEV_CONTAINER_REGISTRY }}
3433
DEV_LOGIN_USERNAME: ${{ secrets.DEV_LOGIN_USERNAME }}
3534
DEV_LOGIN_PASSWORD: ${{ secrets.DEV_LOGIN_PASSWORD }}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: 'DC: Bulk Delete Registry Images'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
delete_since_days:
7+
required: false
8+
type: string
9+
description: "Delete images older than the specified number of days and exit gracefully"
10+
default: ''
11+
12+
env:
13+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
14+
15+
jobs:
16+
dc-generate-matrix:
17+
name: 'Docker Compose: Get Images to Bulk Delete'
18+
runs-on: ubuntu-latest
19+
environment: dev
20+
env:
21+
ENVIRONMENT_NAME: dev
22+
DEV_CONTAINER_REGISTRY: ${{ vars.DEV_CONTAINER_REGISTRY }}
23+
DEV_LOGIN_USERNAME: ${{ secrets.DEV_LOGIN_USERNAME }}
24+
DEV_LOGIN_PASSWORD: ${{ secrets.DEV_LOGIN_PASSWORD }}
25+
outputs:
26+
app_name: ${{ steps.generate-matrix.outputs.app_name }}
27+
steps:
28+
# Checkout the repository to the GitHub Actions runner
29+
- name: Checkout cicd-deployment-scripts
30+
uses: actions/checkout@v4
31+
with:
32+
repository: 'code-kern-ai/cicd-deployment-scripts'
33+
34+
- name: Generate Matrix
35+
id: generate-matrix
36+
run: |
37+
app_names=$(curl -s -u "${{ env.DEV_LOGIN_USERNAME }}:${{ env.DEV_LOGIN_PASSWORD }}" \
38+
https://${{ env.DEV_CONTAINER_REGISTRY }}/v2/_catalog \
39+
| jq -c '[.repositories[] | split("/") | .[1]]')
40+
echo "app_name=$app_names" >> $GITHUB_OUTPUT
41+
42+
dc-registry-delete-bulk:
43+
name: 'Docker Compose: Bulk Delete Registry Images'
44+
runs-on: ubuntu-latest
45+
needs: dc-generate-matrix
46+
environment: dev
47+
env:
48+
ENVIRONMENT_NAME: dev
49+
DEV_CONTAINER_REGISTRY: ${{ vars.DEV_CONTAINER_REGISTRY }}
50+
DEV_LOGIN_USERNAME: ${{ secrets.DEV_LOGIN_USERNAME }}
51+
DEV_LOGIN_PASSWORD: ${{ secrets.DEV_LOGIN_PASSWORD }}
52+
strategy:
53+
matrix:
54+
app_name: ${{ fromJson(needs.dc-generate-matrix.outputs.app_name) }}
55+
steps:
56+
# Checkout the repository to the GitHub Actions runner
57+
- name: Checkout cicd-deployment-scripts
58+
uses: actions/checkout@v4
59+
with:
60+
repository: 'code-kern-ai/cicd-deployment-scripts'
61+
62+
- name: Perform Registry Image Deletion
63+
shell: bash
64+
run: |
65+
bash ./dc/registry_delete.sh \
66+
-e ${{ env.ENVIRONMENT_NAME }} \
67+
-g ${{ github.repository_owner }} \
68+
-r ${{ env.DEV_CONTAINER_REGISTRY }} \
69+
-a ${{ matrix.app_name }} \
70+
-t "" \
71+
-u "${{ env.DEV_LOGIN_USERNAME }}:${{ env.DEV_LOGIN_PASSWORD }}" \
72+
-d "${{ inputs.delete_since_days }}"

0 commit comments

Comments
 (0)