-
Notifications
You must be signed in to change notification settings - Fork 30
53 lines (53 loc) · 1.62 KB
/
test-policies.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: test-policies
on:
push:
branches:
- main
paths:
- ".github/workflows/**"
- "policies/**"
- "tests/**"
- "utils/**"
workflow_dispatch:
inputs:
remarks:
description: "Reason for triggering the workflow run"
required: false
default: "Testing Azure Policies..."
jobs:
test-policies:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install PowerShell modules
shell: pwsh
run: |
Install-Module -Name "Az" -RequiredVersion "4.7.0" -Force -Scope CurrentUser -ErrorAction Stop
- name: Login to Azure
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
enable-AzPSSession: true
- name: Create or update Azure Policies
shell: pwsh
run: |
Get-ChildItem -Path "./policies" | ForEach-Object {
New-AzDeployment -Location "northeurope" -TemplateFile $_.FullName
}
# Logout/Login to Azure to ensure that the latest policies are applied
- name: Logout of Azure
shell: pwsh
run: |
# Suppress printing out client secret in clear text by sending output to $null.
# See also: https://github.com/Azure/azure-powershell/issues/14208
Disconnect-AzAccount > $null
- name: Login to Azure
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
enable-AzPSSession: true
- name: Test Azure Policies
shell: pwsh
run: |
Invoke-Pester -Output Detailed -CI