Last active
July 5, 2022 12:34
-
-
Save stevengonsalvez/f1374d79b07f757f502799b5309709ed to your computer and use it in GitHub Desktop.
god mode clean azure action pipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: GOD-MOD-Clean-up | |
on: | |
workflow_dispatch: | |
inputs: | |
AZURE_CREDENTIALS: | |
description: 'AZURE_CREDENTIALS as secrets in the format {"clientId": "<GUID>","clientSecret": "<GUID>","subscriptionId": "<GUID>","tenantId": "<GUID>" }' | |
required: false | |
jobs: | |
get-stuff-to-delete: | |
runs-on: ubuntu-latest | |
environment: | |
name: Nonprod | |
steps: | |
- name: "Login via Azure CLI" | |
uses: azure/login@v1 | |
with: | |
creds: '{"clientId": "${{ secrets.SP_CLIENT_ID }}", "clientSecret": "${{ secrets.SP_PASSWORD }}", "subscriptionId": "${{ secrets.SUBSCRIPTION_ID }}", "tenantId": "bd5c6713-7399-4b31-be79-78f2d078e543"}' | |
- name: 'will delete these RGs next' | |
run: | | |
az group list --query "[].name" -o tsv | |
deleting-stuff: | |
needs: get-stuff-to-delete | |
environment: | |
name: Nonprod | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Login via Azure CLI" | |
uses: azure/login@v1 | |
with: | |
creds: '{"clientId": "${{ secrets.SP_CLIENT_ID }}", "clientSecret": "${{ secrets.SP_PASSWORD }}", "subscriptionId": "${{ secrets.SUBSCRIPTION_ID }}", "tenantId": "bd5c6713-7399-4b31-be79-78f2d078e543"}' | |
- name: 'deleting these RGs' | |
run: | | |
for rgname in `az group list --query "[].name" -o tsv`; do | |
echo Deleting ${rgname} | |
az group delete -n ${rgname} --yes --no-wait | |
done | |
get-stuff-to-delete-prod: | |
runs-on: ubuntu-latest | |
environment: | |
name: prod | |
steps: | |
- name: "Login via Azure CLI" | |
uses: azure/login@v1 | |
with: | |
creds: '{"clientId": "${{ secrets.SP_CLIENT_ID }}", "clientSecret": "${{ secrets.SP_PASSWORD }}", "subscriptionId": "${{ secrets.SUBSCRIPTION_ID }}", "tenantId": "bd5c6713-7399-4b31-be79-78f2d078e543"}' | |
- name: 'will delete these RGs next' | |
run: | | |
az group list --query "[].name" -o tsv | |
deleting-stuff-prod: | |
needs: get-stuff-to-delete | |
environment: | |
name: prod | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Login via Azure CLI" | |
uses: azure/login@v1 | |
with: | |
creds: '{"clientId": "${{ secrets.SP_CLIENT_ID }}", "clientSecret": "${{ secrets.SP_PASSWORD }}", "subscriptionId": "${{ secrets.SUBSCRIPTION_ID }}", "tenantId": "bd5c6713-7399-4b31-be79-78f2d078e543"}' | |
- name: 'deleting these RGs' | |
run: | | |
for rgname in `az group list --query "[].name" -o tsv`; do | |
echo Deleting ${rgname} | |
az group delete -n ${rgname} --yes --no-wait | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment