-
Notifications
You must be signed in to change notification settings - Fork 517
78 lines (71 loc) · 3.42 KB
/
ResourceIntegration.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Resource Integration
on: [push]
jobs:
ResourceIntegration:
runs-on: windows-latest
# Only when run from the main repo
if: github.repository == 'microsoft/Microsoft365DSC'
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v34
- uses: actions/checkout@v3
- name: Install Microsoft365DSC
shell: powershell
run: |
winrm quickconfig -force
$source = "./Modules/Microsoft365DSC/"
$destination = "C:\Program Files\WindowsPowerShell\Modules"
Copy-Item -Path $source -Recurse -Destination $destination -Container -Force
Update-M365DSCDependencies
- name: Detect Changed Files
shell: powershell
env:
PUBLIC_USERNAME: ${{ secrets.PUBLIC_USERNAME }}
PUBLIC_PASSWORD: ${{ secrets.PUBLIC_PASSWORD }}
APPLICATIONID: ${{ secrets.APPLICATIONID }}
TENANTID: ${{ secrets.TENANTID }}
CERTIFICATETHUMBPRINT: ${{ secrets.CERTIFICATETHUMBPRINT }}
APPLICATIONSECRET: ${{ secrets.APPLICATIONSECRET }}
run: |
Set-ExecutionPolicy Unrestricted -Force
Get-ChildItem "C:\Program Files\WindowsPowerShell\Modules" -Recurse | Unblock-File
$files = "${{ steps.changed-files.outputs.all_changed_files }}".Split(' ')
$modifiedResources = @()
foreach ($file in $files)
{
Write-Host "Current File -> $file"
if ($file.ToLower().StartsWith("modules/microsoft365dsc/dscresources/msft_"))
{
$start = $file.IndexOf("MSFT_")
$end = $file.IndexOf('/', $start + 5)
$currentResource = $file.Substring($start, $end - $start)
Write-Host "Found $currentResource as a modified resource"
$modifiedResources += $currentResource
$integrationTestPath = "Tests/Integration/Microsoft365DSC/$currentResource.ps1"
if (Test-Path $integrationTestPath)
{
Write-Host "Will execute {$integrationTestPath}"
Write-Host "Connecting using {$($env:PUBLIC_USERNAME)}"
$CredPassword = ConvertTo-SecureString $env:PUBLIC_PASSWORD -AsPlainText -Force
$CredSecret = ConvertTo-SecureString $env:APPLICATIONSECRET -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential($env:PUBLIC_USERNAME, $CredPassword)
$params = @{
Credential = $Credential
ApplicationId = $env:APPLICATIONID
TenantId = $env:TENANTID
CertificateThumbprint = $env:CERTIFICATETHUMBPRINT
ApplicationSecret = New-Object System.Management.Automation.PSCredential("ApplicationSecret", $CredSecret)
}
& $integrationTestPath @params
}
else
{
Write-Host "Integration Test for resource {$currentResource} doesn't exist at path {$integrationTestPath}"
}
}
}