-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: 'Power ON/OFF or DEALLOCATE a specific Azure VM' | ||
description: 'This action either powers on/off or deallocates a specific Azure VM' | ||
|
||
branding: | ||
icon: download | ||
color: blue | ||
|
||
inputs: | ||
POWER_SWITCH: | ||
description: 'Turn ON or OFF the VM, or DEALLOCATE' | ||
required: true | ||
type: string | ||
AZURE_VM_NAME: | ||
description: 'Name of the VM' | ||
required: true | ||
AZURE_RG_NAME: | ||
description: 'Resource Group where the VM lives' | ||
required: true | ||
AZURE_SP_CLIENTID: | ||
description: 'Service Principal ClientID' | ||
required: true | ||
AZURE_SP_SECRET: | ||
description: 'Service Principal Secret' | ||
required: true | ||
AZURE_TENANTID: | ||
description: 'Service Principal TenantID' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: "Login with az CLI" | ||
shell: bash | ||
run: | | ||
az login --service-principal -u ${{ inputs.AZURE_SP_CLIENTID }} -p ${{ inputs.AZURE_SP_SECRET }} --tenant ${{ inputs.AZURE_TENANTID }} | ||
- name: 'Debug POWER' | ||
shell: bash | ||
run: | | ||
echo ${{ inputs.POWER_SWITCH }} | ||
- name: "Deallocate VM" | ||
shell: bash | ||
if: ${{ inputs.POWER_SWITCH == 'DEALLOCATE' }} | ||
run: | | ||
az vm deallocate --name ${{ inputs.AZURE_VM_NAME }} --resource-group ${{ inputs.AZURE_RG_NAME }} --no-wait | ||
- name: "Stop VM" | ||
shell: bash | ||
if: ${{ inputs.POWER_SWITCH == 'OFF' }} | ||
run: | | ||
az vm stop --name ${{ inputs.AZURE_VM_NAME }} --resource-group ${{ inputs.AZURE_RG_NAME }} --no-wait | ||
- name: "Start VM" | ||
shell: bash | ||
if: ${{ inputs.POWER_SWITCH == 'ON' }} | ||
run: | | ||
az vm start --name ${{ inputs.AZURE_VM_NAME }} --resource-group ${{ inputs.AZURE_RG_NAME }} --no-wait |