Skip to content

Merge branch 'Dev' into 5207_AddProvisionDatabase #368

Merge branch 'Dev' into 5207_AddProvisionDatabase

Merge branch 'Dev' into 5207_AddProvisionDatabase #368

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}"
}
}
}