Deprovision Azure Resources #5
This file contains 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: 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 | |