Skip to content

Commit

Permalink
add action to root for marketplace
Browse files Browse the repository at this point in the history
  • Loading branch information
roel4ez committed Dec 21, 2021
1 parent f3f7998 commit 98ad900
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ The action requires 6 different parameters:
- `AZURE_SP_SECRET`: The secret of the ServicePrincipal
- `AZURE_TENANTID`: TenantID where the ServicePrincipal belongs to.



## Example

See the [main-flow.yml](.github/workflows/main-flow.yml) for an example on how
Expand Down
58 changes: 58 additions & 0 deletions action.yml
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

0 comments on commit 98ad900

Please sign in to comment.