Shutdown VMs #1291
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: Shutdown VMs | |
on: | |
schedule: | |
- cron: "0 23 * * *" | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
shutdown_vms: | |
name: Shutdown all virtual machines | |
runs-on: ubuntu-latest | |
steps: | |
- name: Azure Login | |
uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Shutdown all virtual machines | |
run: | | |
set -e | |
VIRTUAL_MACHINES=$(az vm list --query "[].id" --output tsv) | |
for VIRTUAL_MACHINE in "${VIRTUAL_MACHINES}"; do | |
az vm stop --ids "${VIRTUAL_MACHINE}" | |
az vm deallocate --ids "${VIRTUAL_MACHINE}" | |
done |