Skip to content

Commit a5c4ba0

Browse files
author
naman-msft
committed
fixed resource deletion logic
1 parent 0609cd9 commit a5c4ba0

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

.github/workflows/script-cleanup.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010
contents: write
1111
id-token: write
1212
issues: write
13-
13+
1414
jobs:
1515
cleanup:
1616
runs-on: ubuntu-latest
@@ -34,15 +34,25 @@ jobs:
3434
"myStaticWebAppResourceGroup" "contoso" "ignite" "SpringBoot"
3535
"SpeechAppGroup" "MC_"
3636
)
37-
# fetch once
3837
rgs=$(az group list --output json)
3938
39+
# don’t exit on errors in this block
40+
set +e
41+
4042
for sub in "${substrings[@]}"; do
4143
echo "Looking for RGs containing '$sub'…"
4244
echo "$rgs" |
4345
jq -r --arg s "$sub" '.[] | select(.name | contains($s)) | .name' |
4446
while read -r rg; do
45-
echo "Deleting $rg"
46-
az group delete --name "$rg" --yes --no-wait
47+
echo -n "Deleting $rg… "
48+
az group delete \
49+
--name "$rg" \
50+
--yes \
51+
--no-wait \
52+
&& echo "OK" \
53+
|| echo "⚠️ Skipped (deny-assignment or other error)"
4754
done
4855
done
56+
57+
# restore “exit on error” if you need it later
58+
set -e

0 commit comments

Comments
 (0)