Skip to content

Deprovision Azure Resources #5

Deprovision Azure Resources

Deprovision Azure Resources #5

name: Deprovision Azure Resources
on:
workflow_dispatch:
jobs:
delete-resource-groups:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Login to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Read GitHub handles from file
id: read-handles
run: |
echo "::set-output name=handles::$(cat provisioning/cleanup-handles.txt)"
- name: Loop through handles and delete resource groups
run: |
for handle in ${{ steps.read-handles.outputs.handles }}; do
run: |
echo "Deleting resource group: $handle"
az group delete --name $handle --yes
done
#remove user from AAD
- name: Remove user from AAD
run: |
for handle in ${{ steps.read-handles.outputs.handles }}; do
run: |
echo "Deleting user: $handle"
az ad user delete --upn-or-object-id $handle
done