-
Notifications
You must be signed in to change notification settings - Fork 14
96 lines (82 loc) · 2.66 KB
/
cleanup.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
name: Cleanup
permissions:
id-token: write
contents: read
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
jobs:
cleanup-aci:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log into Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.MANAGED_ID_CLIENT_ID }}
tenant-id: ${{ secrets.MANAGED_ID_TENANT_ID }}
subscription-id: 7ca35580-fc67-469c-91a7-68b38569ca6e
- run: |
source services/cacitesting.env
aci_names=$(az container list \
--resource-group "$RESOURCE_GROUP" \
--query "[?starts_with(name, 'kms-') || starts_with(name, 'lb-')].name" \
-o tsv)
for name in $aci_names; do
echo "Deleting ACI: $name"
az container delete \
--name "$name" \
--resource-group "$RESOURCE_GROUP" \
--yes
done
cleanup-storage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log into Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.MANAGED_ID_CLIENT_ID }}
tenant-id: ${{ secrets.MANAGED_ID_TENANT_ID }}
subscription-id: 7ca35580-fc67-469c-91a7-68b38569ca6e
- run: |
source services/cacitesting.env
storage_accounts=$(az storage account list \
--resource-group "$RESOURCE_GROUP" \
--query "[?starts_with(name, 'ccf')].name" \
-o tsv)
# Loop through each storage account and delete it
for account in $storage_accounts; do
echo "Deleting Storage Account: $account"
az storage account delete \
--name "$account" \
--resource-group "$RESOURCE_GROUP" \
--yes
done
cleanup-akv:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log into Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.MANAGED_ID_CLIENT_ID }}
tenant-id: ${{ secrets.MANAGED_ID_TENANT_ID }}
subscription-id: 7ca35580-fc67-469c-91a7-68b38569ca6e
- run: |
source services/cacitesting.env
key_vaults=$(az keyvault list \
--resource-group "$RESOURCE_GROUP" \
--query "[].name" \
-o tsv \
)
for kv in $key_vaults; do
echo "Deleting Key Vault: $kv"
az keyvault delete \
--name "$kv" \
--resource-group "$RESOURCE_GROUP" > /dev/null 2>&1
done