File tree Expand file tree Collapse file tree 2 files changed +56
-2
lines changed
Expand file tree Collapse file tree 2 files changed +56
-2
lines changed Original file line number Diff line number Diff line change 1+ name : Daily RG Cleanup
2+
3+ on :
4+ schedule :
5+ # runs every day at 11:11 UTC
6+ - cron : ' 11 11 * * *'
7+ workflow_dispatch :
8+
9+ permissions :
10+ contents : write
11+ id-token : write
12+ issues : write
13+
14+ jobs :
15+ cleanup :
16+ runs-on : ubuntu-latest
17+ steps :
18+ - name : ' Az CLI login'
19+ uses : azure/login@v1
20+ with :
21+ client-id : ${{ secrets.AZURE_CLIENT_ID }}
22+ tenant-id : ${{ secrets.AZURE_TENANT_ID }}
23+ subscription-id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
24+
25+ - name : Install jq
26+ run : sudo apt-get update && sudo apt-get install -y jq
27+
28+ - name : Cleanup Resource Groups
29+ run : |
30+ echo "Fetching all resource groups in the subscription..."
31+ rgs_json=$(az group list --output json)
32+
33+ # don’t exit on errors in this block
34+ set +e
35+
36+ echo "Attempting to delete all resource groups..."
37+ echo "$rgs_json" |
38+ jq -r '.[] | .name' |
39+ while read -r rg_name; do
40+ if [[ -z "$rg_name" ]]; then
41+ echo "Skipping empty resource group name."
42+ continue
43+ fi
44+ echo -n "Deleting $rg_name… "
45+ az group delete \
46+ --name "$rg_name" \
47+ --yes \
48+ --no-wait \
49+ && echo "OK" \
50+ || echo "⚠️ Skipped (deny-assignment or other error)"
51+ done
52+
53+ # restore “exit on error” if you need it later
54+ set -e
Original file line number Diff line number Diff line change 11name : Sync Markdown Files
22
33on :
4- schedule :
5- - cron : ' 0 15 * * *'
4+ # schedule:
5+ # - cron: '0 15 * * *'
66 workflow_dispatch :
77
88permissions :
You can’t perform that action at this time.
0 commit comments