Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# This is a basic workflow to help you get started with Actions
name: Deploy_ARM
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
[push, pull_request]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Azure Login
uses: Azure/login@v1.1
with:
creds: ${{ secrets.AZURE_CREDS }}
# Set this value to true to enable Azure PowerShell Login in addition to Az CLI login
enable-AzPSSession: true
- name: Install Module
uses: Azure/powershell@v1
with:
# Specify the Az PowerShell script here.
inlineScript: |
Install-Module Az.Resources -RequiredVersion 1.12.1-preview -AllowPrerelease -Force -Scope CurrentUser -AllowClobber
# Azure PS version to be used to execute the script, example: 1.8.0, 2.8.0, 3.4.0. To use the latest version, specify "latest".
azPSVersion: latest
- name: Show resources
uses: Azure/powershell@v1
with:
# Specify the Az PowerShell script here.
inlineScript: |
$Parameters = @{
ResourcegroupName = "ARMDeploymentTest"
Templatefile = ".\StorageAccount\azuredeploy.json"
TemplateParameterfile = ".\StorageAccount\azuredeploy.parameters.json"
Mode = 'Incremental'
}
$Result = Get-AzResourceGroupDeploymentWhatIfResult @Parameters
$Result
# Azure PS version to be used to execute the script, example: 1.8.0, 2.8.0, 3.4.0. To use the latest version, specify "latest".
azPSVersion: latest
- name: Check for deleted resources
uses: Azure/powershell@v1
with:
# Specify the Az PowerShell script here.
inlineScript: .\Tests\CheckForDeletion.ps1 -ResourceGroup ARMDeploymentTest
# Azure PS version to be used to execute the script, example: 1.8.0, 2.8.0, 3.4.0. To use the latest version, specify "latest".
azPSVersion: latest
# This workflow contains a single job called "build"
deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs: build
steps:
- uses: actions/checkout@v2
- name: Azure Login
uses: Azure/login@v1.1
with:
creds: ${{ secrets.AZURE_CREDS }}
# Set this value to true to enable Azure PowerShell Login in addition to Az CLI login
enable-AzPSSession: true
- name: Deploy Resources
uses: Azure/powershell@v1
with:
# Specify the Az PowerShell script here.
inlineScript: |
$Parameters = @{
ResourcegroupName = "ARMDeploymentTest"
Templatefile = ".\StorageAccount\azuredeploy.json"
TemplateParameterfile = ".\StorageAccount\azuredeploy.parameters.json"
Mode = 'Incremental'
}
$Result = New-AZResourceGroupDeployment @Parameters
$Result
# Azure PS version to be used to execute the script, example: 1.8.0, 2.8.0, 3.4.0. To use the latest version, specify "latest".
azPSVersion: latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment