Merge pull request #8 from andersgMSFT/main #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ' CI/CD' | |
on: | |
workflow_dispatch: | |
push: | |
paths-ignore: | |
- '**.md' | |
- '.github/workflows/*.yaml' | |
- '!.github/workflows/CICD.yaml' | |
branches: [ 'main', 'release/*', 'feature/*' ] | |
defaults: | |
run: | |
shell: powershell | |
permissions: | |
contents: read | |
actions: read | |
env: | |
workflowDepth: 1 | |
ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} | |
ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} | |
jobs: | |
Initialization: | |
runs-on: [ windows-latest ] | |
outputs: | |
telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} | |
settings: ${{ steps.ReadSettings.outputs.SettingsJson }} | |
environments: ${{ steps.ReadSettings.outputs.EnvironmentsJson }} | |
environmentCount: ${{ steps.ReadSettings.outputs.EnvironmentCount }} | |
deliveryTargets: ${{ steps.DetermineDeliveryTargets.outputs.DeliveryTargetsJson }} | |
deliveryTargetCount: ${{ steps.DetermineDeliveryTargets.outputs.DeliveryTargetCount }} | |
githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} | |
githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} | |
checkRunId: ${{ steps.CreateCheckRun.outputs.checkRunId }} | |
projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }} | |
projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }} | |
buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- name: Initialize the workflow | |
id: init | |
uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview | |
with: | |
shell: powershell | |
eventId: "DO0091" | |
- name: Read settings | |
id: ReadSettings | |
uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview | |
with: | |
shell: powershell | |
parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} | |
getEnvironments: '*' | |
- name: Determine Projects To Build | |
id: determineProjectsToBuild | |
uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@PPPreview | |
with: | |
shell: powershell | |
maxBuildDepth: ${{ env.workflowDepth }} | |
- name: Determine Delivery Target Secrets | |
id: DetermineDeliveryTargetSecrets | |
run: | | |
$ErrorActionPreference = "STOP" | |
Set-StrictMode -version 2.0 | |
$deliveryTargetSecrets = @('GitHubPackagesContext','NuGetContext','StorageContext','AppSourceContext') | |
$namePrefix = 'DeliverTo' | |
Get-Item -Path (Join-Path $ENV:GITHUB_WORKSPACE ".github/$($namePrefix)*.ps1") | ForEach-Object { | |
$deliveryTarget = [System.IO.Path]::GetFileNameWithoutExtension($_.Name.SubString($namePrefix.Length)) | |
$deliveryTargetSecrets += @("$($deliveryTarget)Context") | |
} | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "Secrets=$($deliveryTargetSecrets -join ',')" | |
- name: Read secrets | |
uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview | |
env: | |
secrets: ${{ toJson(secrets) }} | |
with: | |
shell: powershell | |
settingsJson: ${{ env.Settings }} | |
secrets: ${{ steps.DetermineDeliveryTargetSecrets.outputs.Secrets }} | |
- name: Determine Delivery Targets | |
id: DetermineDeliveryTargets | |
run: | | |
$ErrorActionPreference = "STOP" | |
Set-StrictMode -version 2.0 | |
$deliveryTargets = @('GitHubPackages','NuGet','Storage') | |
if ($env:type -eq "AppSource App") { | |
$continuousDelivery = $false | |
# For multi-project repositories, we will add deliveryTarget AppSource if any project has AppSourceContinuousDelivery set to true | |
('${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}' | ConvertFrom-Json) | where-Object { $_ } | ForEach-Object { | |
$projectSettings = Get-Content (Join-Path $_ '.AL-Go/settings.json') -raw | ConvertFrom-Json | |
if ($projectSettings.PSObject.Properties.Name -eq 'AppSourceContinuousDelivery' -and $projectSettings.AppSourceContinuousDelivery) { | |
Write-Host "Project $_ is setup for Continuous Delivery" | |
$continuousDelivery = $true | |
} | |
} | |
if ($continuousDelivery) { | |
$deliveryTargets += @("AppSource") | |
} | |
} | |
$namePrefix = 'DeliverTo' | |
Get-Item -Path (Join-Path $ENV:GITHUB_WORKSPACE ".github/$($namePrefix)*.ps1") | ForEach-Object { | |
$deliveryTarget = [System.IO.Path]::GetFileNameWithoutExtension($_.Name.SubString($namePrefix.Length)) | |
$deliveryTargets += @($deliveryTarget) | |
} | |
$deliveryTargets = @($deliveryTargets | Select-Object -unique | Where-Object { | |
$include = $false | |
Write-Host "Check DeliveryTarget $_" | |
$contextName = "$($_)Context" | |
$deliveryContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($contextName))) | |
if ($deliveryContext) { | |
$settingName = "DeliverTo$_" | |
$settings = $env:Settings | ConvertFrom-Json | |
if (($settings.PSObject.Properties.Name -eq $settingName) -and ($settings."$settingName".PSObject.Properties.Name -eq "Branches")) { | |
Write-Host "Branches:" | |
$settings."$settingName".Branches | ForEach-Object { | |
Write-Host "- $_" | |
if ($ENV:GITHUB_REF_NAME -like $_) { | |
$include = $true | |
} | |
} | |
} | |
else { | |
$include = ($ENV:GITHUB_REF_NAME -eq 'main') | |
} | |
} | |
if ($include) { | |
Write-Host "DeliveryTarget $_ included" | |
} | |
$include | |
}) | |
$deliveryTargetsJson = $deliveryTargets | ConvertTo-Json -Depth 99 -compress | |
if ($deliveryTargets.Count -lt 2) { $deliveryTargetsJson = "[$($deliveryTargetsJson)]" } | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "DeliveryTargetsJson=$deliveryTargetsJson" | |
Write-Host "DeliveryTargetsJson=$deliveryTargetsJson" | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "DeliveryTargetCount=$($deliveryTargets.Count)" | |
Write-Host "DeliveryTargetCount=$($deliveryTargets.Count)" | |
Add-Content -Path $env:GITHUB_ENV -Value "DeliveryTargets=$deliveryTargetsJson" | |
CheckForUpdates: | |
runs-on: [ windows-latest ] | |
needs: [ Initialization ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Read settings | |
uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview | |
with: | |
shell: powershell | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
get: templateUrl | |
- name: Check for updates to AL-Go system files | |
uses: microsoft/AL-Go-Actions/CheckForUpdates@PPPreview | |
with: | |
shell: powershell | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
templateUrl: ${{ env.templateUrl }} | |
Build: | |
needs: [ Initialization ] | |
if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 | |
runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} | |
defaults: | |
run: | |
shell: ${{ needs.Initialization.outputs.githubRunnerShell }} | |
strategy: | |
matrix: | |
include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} | |
fail-fast: false | |
name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} | |
outputs: | |
AppsArtifactsName: ${{ steps.calculateArtifactNames.outputs.AppsArtifactsName }} | |
TestAppsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestAppsArtifactsName }} | |
TestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestResultsArtifactsName }} | |
BcptTestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.BcptTestResultsArtifactsName }} | |
BuildOutputArtifactsName: ${{ steps.calculateArtifactNames.outputs.BuildOutputArtifactsName }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- name: Download thisbuild artifacts | |
if: env.workflowDepth > 1 | |
uses: actions/download-artifact@v3 | |
with: | |
path: '.dependencies' | |
- name: Read settings | |
uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview | |
with: | |
shell: ${{ needs.Initialization.outputs.githubRunnerShell }} | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
project: ${{ matrix.project }} | |
- name: Read secrets | |
uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview | |
env: | |
secrets: ${{ toJson(secrets) }} | |
with: | |
shell: ${{ needs.Initialization.outputs.githubRunnerShell }} | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
settingsJson: ${{ env.Settings }} | |
secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,storageContext,gitHubPackagesContext' | |
- name: Determine ArtifactUrl | |
uses: microsoft/AL-Go-Actions/DetermineArtifactUrl@PPPreview | |
id: determineArtifactUrl | |
with: | |
shell: ${{ needs.Initialization.outputs.githubRunnerShell }} | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
project: ${{ matrix.project }} | |
settingsJson: ${{ env.Settings }} | |
secretsJson: ${{ env.RepoSecrets }} | |
- name: Cache Business Central Artifacts | |
if: env.useCompilerFolder == 'True' && steps.determineArtifactUrl.outputs.ArtifactUrl && !contains(env.artifact,'INSIDERSASTOKEN') | |
uses: actions/cache@v3 | |
with: | |
path: .artifactcache | |
key: ${{ steps.determineArtifactUrl.outputs.ArtifactUrl }} | |
- name: Build AL Project | |
id: RunPipeline | |
if: matrix.project != env.powerPlatformSolutionFolder | |
uses: microsoft/AL-Go-Actions/RunPipeline@PPPreview | |
env: | |
BuildMode: ${{ matrix.buildMode }} | |
with: | |
shell: ${{ needs.Initialization.outputs.githubRunnerShell }} | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
project: ${{ matrix.project }} | |
projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} | |
settingsJson: ${{ env.Settings }} | |
secretsJson: ${{ env.RepoSecrets }} | |
buildMode: ${{ matrix.buildMode }} | |
- name: Build PowerPlatform Solution | |
id: BuildPowerPlatform | |
if: matrix.project == env.powerPlatformSolutionFolder && matrix.buildMode == 'default' | |
uses: microsoft/AL-Go-Actions/BuildPowerPlatform@PPPreview | |
with: | |
shell: ${{ needs.Initialization.outputs.githubRunnerShell }} | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
solutionFolder: ${{ matrix.project }} | |
outputFolder: ${{ matrix.project }}/.buildartifacts/PowerPlatformSolution/ | |
outputFileName: ${{ matrix.project }} | |
appRevision: ${{ env.appRevision }} | |
appBuild: ${{ env.appBuild }} | |
- name: Calculate Artifact names | |
id: calculateArtifactsNames | |
uses: microsoft/AL-Go-Actions/CalculateArtifactNames@PPPreview | |
if: success() || failure() | |
with: | |
shell: ${{ needs.Initialization.outputs.githubRunnerShell }} | |
settingsJson: ${{ env.Settings }} | |
project: ${{ matrix.project }} | |
buildMode: ${{ matrix.buildMode }} | |
branchName: ${{ github.ref_name }} | |
- name: Upload thisbuild artifacts - apps | |
if: env.workflowDepth > 1 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }} | |
path: '${{ matrix.project }}/.buildartifacts/Apps/' | |
if-no-files-found: ignore | |
retention-days: 1 | |
- name: Upload thisbuild artifacts - test apps | |
if: env.workflowDepth > 1 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildTestAppsArtifactsName }} | |
path: '${{ matrix.project }}/.buildartifacts/TestApps/' | |
if-no-files-found: ignore | |
retention-days: 1 | |
- name: Publish artifacts - apps | |
uses: actions/upload-artifact@v3 | |
if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 | |
with: | |
name: ${{ env.AppsArtifactsName }} | |
path: '${{ matrix.project }}/.buildartifacts/Apps/' | |
if-no-files-found: ignore | |
- name: Publish artifacts - dependencies | |
uses: actions/upload-artifact@v3 | |
if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 | |
with: | |
name: ${{ env.DependenciesArtifactsName }} | |
path: '${{ matrix.project }}/.buildartifacts/Dependencies/' | |
if-no-files-found: ignore | |
- name: Publish artifacts - test apps | |
uses: actions/upload-artifact@v3 | |
if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 | |
with: | |
name: ${{ env.TestAppsArtifactsName }} | |
path: '${{ matrix.project }}/.buildartifacts/TestApps/' | |
if-no-files-found: ignore | |
- name: Publish artifacts - build output | |
uses: actions/upload-artifact@v3 | |
if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',matrix.project)) != '') | |
with: | |
name: ${{ env.BuildOutputArtifactsName }} | |
path: '${{ matrix.project }}/BuildOutput.txt' | |
if-no-files-found: ignore | |
- name: Publish artifacts - container event log | |
uses: actions/upload-artifact@v3 | |
if: (failure()) && (hashFiles(format('{0}/ContainerEventLog.evtx',matrix.project)) != '') | |
with: | |
name: ${{ env.ContainerEventLogArtifactsName }} | |
path: '${{ matrix.project }}/ContainerEventLog.evtx' | |
if-no-files-found: ignore | |
- name: Publish artifacts - test results | |
uses: actions/upload-artifact@v3 | |
if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',matrix.project)) != '') | |
with: | |
name: ${{ env.TestResultsArtifactsName }} | |
path: '${{ matrix.project }}/TestResults.xml' | |
if-no-files-found: ignore | |
- name: Publish artifacts - bcpt test results | |
uses: actions/upload-artifact@v3 | |
if: (success() || failure()) && (hashFiles(format('{0}/bcptTestResults.json',matrix.project)) != '') | |
with: | |
name: ${{ env.BcptTestResultsArtifactsName }} | |
path: '${{ matrix.project }}/bcptTestResults.json' | |
if-no-files-found: ignore | |
- name: Publish artifacts - Power Platform Solution | |
uses: actions/upload-artifact@v3 | |
if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 | |
with: | |
name: ${{ env.PowerPlatformSolutionArtifactsName }} | |
path: '${{ matrix.project }}/.buildartifacts/PowerPlatformSolution/' | |
if-no-files-found: ignore | |
- name: Analyze Test Results | |
id: analyzeTestResults | |
if: success() || failure() | |
uses: microsoft/AL-Go-Actions/AnalyzeTests@PPPreview | |
with: | |
shell: ${{ needs.Initialization.outputs.githubRunnerShell }} | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
Project: ${{ matrix.project }} | |
- name: Cleanup | |
if: always() | |
uses: microsoft/AL-Go-Actions/PipelineCleanup@PPPreview | |
with: | |
shell: ${{ needs.Initialization.outputs.githubRunnerShell }} | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
Project: ${{ matrix.project }} | |
Deploy: | |
needs: [ Initialization, Build ] | |
if: always() && needs.Build.result == 'Success' && needs.Initialization.outputs.environmentCount > 0 | |
strategy: ${{ fromJson(needs.Initialization.outputs.environments) }} | |
runs-on: ${{ fromJson(matrix.os) }} | |
name: Deploy to ${{ matrix.environment }} | |
environment: | |
name: ${{ matrix.environment }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: '.artifacts' | |
- name: EnvName | |
id: envName | |
run: | | |
$ErrorActionPreference = "STOP" | |
Set-StrictMode -version 2.0 | |
$envName = '${{ matrix.environment }}'.split(' ')[0] | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "envName=$envName" | |
- name: Read settings | |
uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview | |
with: | |
shell: powershell | |
- name: Read secrets | |
uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview | |
env: | |
secrets: ${{ toJson(secrets) }} | |
with: | |
shell: powershell | |
settingsJson: ${{ env.Settings }} | |
secrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,projects' | |
- name: AuthContext | |
id: authContext | |
run: | | |
$ErrorActionPreference = "STOP" | |
Set-StrictMode -version 2.0 | |
$envName = '${{ steps.envName.outputs.envName }}' | |
$deployToSettingStr = [System.Environment]::GetEnvironmentVariable("DeployTo$envName") | |
if ($deployToSettingStr) { | |
$deployToSettings = $deployToSettingStr | ConvertFrom-Json | |
} | |
else { | |
$deployToSettings = [PSCustomObject]@{} | |
} | |
$authContext = $null | |
"$($envName)-AuthContext", "$($envName)_AuthContext", "AuthContext" | ForEach-Object { | |
if (!($authContext)) { | |
$authContext = [System.Environment]::GetEnvironmentVariable($_) | |
if ($authContext) { | |
Write-Host "Using $_ secret as AuthContext" | |
} | |
} | |
} | |
if (!($authContext)) { | |
Write-Host "::Error::No AuthContext provided" | |
exit 1 | |
} | |
if (("$deployToSettings" -ne "") -and $deployToSettings.PSObject.Properties.name -eq "EnvironmentName") { | |
$environmentName = $deployToSettings.environmentName | |
} | |
else { | |
$environmentName = $null | |
"$($envName)-EnvironmentName", "$($envName)_EnvironmentName", "EnvironmentName" | ForEach-Object { | |
if (!($EnvironmentName)) { | |
$EnvironmentName = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($_))) | |
if ($EnvironmentName) { | |
Write-Host "Using $_ secret as EnvironmentName" | |
Write-Host "Please consider using the DeployTo$_ setting instead, where you can specify EnvironmentName, projects and branches" | |
} | |
} | |
} | |
if (!($environmentName)) { | |
$environmentName = '${{ steps.envName.outputs.envName }}' | |
} | |
$deployToSettings | Add-Member -MemberType NoteProperty -name 'environmentName' -value $environmentName | |
} | |
$environmentName = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(($environmentName + '${{ matrix.environment }}'.SubString($envName.Length)).ToUpperInvariant())) | |
if (("$deployToSettings" -ne "") -and $deployToSettings.PSObject.Properties.name -eq "projects") { | |
$projects = $deployToSettings.projects | |
} | |
else { | |
$projects = [System.Environment]::GetEnvironmentVariable("$($envName)-projects") | |
if (-not $projects) { | |
$projects = [System.Environment]::GetEnvironmentVariable("$($envName)_Projects") | |
if (-not $projects) { | |
$projects = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('projects'))) | |
} | |
} | |
$deployToSettings | Add-Member -MemberType NoteProperty -Name 'projects' -Value $projects | |
} | |
$powerPlatformSolutionFolder = [System.Environment]::GetEnvironmentVariable('PowerPlatformSolutionFolder') | |
$deployPP = $false | |
if ($projects -eq '' -or $projects -eq '*') { | |
$projects = '*' | |
$deployPP = ("$powerPlatformSolutionFolder" -ne "") | |
} | |
else { | |
$buildProjects = '${{ needs.Initialization.outputs.projects }}' | ConvertFrom-Json | |
$projects = ($projects.Split(',') | Where-Object { | |
$deployALProject = $buildProjects -contains $_ | |
if ($_ -eq $powerPlatformSolutionFolder) { | |
$deployPP = $true | |
$deployALProject = $false | |
} | |
$deployALProject | |
}) -join ',' | |
} | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "authContext=$authContext" | |
Write-Host "authContext=$authContext" | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "deployTo=$($deployToSettings | ConvertTo-Json -depth 99 -compress)" | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "environmentName=$environmentName" | |
Write-Host "environmentName=$([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($environmentName)))" | |
Write-Host "environmentName (as Base64)=$environmentName" | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "projects=$projects" | |
Write-Host "projects=$projects" | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "deployPP=$deployPP" | |
Write-Host "deployPP=$deployPP" | |
- name: Deploy AL | |
uses: microsoft/AL-Go-Actions/Deploy@PPPreview | |
if: ${{ steps.authContext.outputs.projects }} | |
env: | |
AuthContext: ${{ steps.authContext.outputs.authContext }} | |
with: | |
shell: powershell | |
type: 'CD' | |
projects: ${{ steps.authContext.outputs.projects }} | |
environmentName: ${{ steps.authContext.outputs.environmentName }} | |
artifacts: '.artifacts' | |
- name: Deploy PowerPlatform | |
if: ${{ steps.authContext.outputs.deployPP == 'true' }} | |
uses: microsoft/AL-Go-Actions/DeployPowerPlatform@PPPreview | |
with: | |
shell: ${{ needs.Initialization.outputs.githubRunnerShell }} | |
parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} | |
artifactPath: '.artifacts' | |
deploySettings: ${{ steps.authContext.outputs.deployTo }} | |
authSettings: ${{ steps.authContext.outputs.authContext }} | |
Deliver: | |
needs: [ Initialization, Build ] | |
if: always() && needs.Build.result == 'Success' && needs.Initialization.outputs.deliveryTargetCount > 0 | |
strategy: | |
matrix: | |
deliveryTarget: ${{ fromJson(needs.Initialization.outputs.deliveryTargets) }} | |
fail-fast: false | |
runs-on: [ windows-latest ] | |
name: Deliver to ${{ matrix.deliveryTarget }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: '.artifacts' | |
- name: Read settings | |
uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview | |
with: | |
shell: powershell | |
- name: Read secrets | |
uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview | |
env: | |
secrets: ${{ toJson(secrets) }} | |
with: | |
shell: powershell | |
settingsJson: ${{ env.Settings }} | |
secrets: '${{ matrix.deliveryTarget }}Context' | |
- name: DeliveryContext | |
id: deliveryContext | |
run: | | |
$ErrorActionPreference = "STOP" | |
Set-StrictMode -version 2.0 | |
$contextName = '${{ matrix.deliveryTarget }}Context' | |
$deliveryContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($contextName))) | |
Add-Content -Path $env:GITHUB_OUTPUT -Value "deliveryContext=$deliveryContext" | |
Write-Host "deliveryContext=$deliveryContext" | |
- name: Deliver | |
uses: microsoft/AL-Go-Actions/Deliver@PPPreview | |
env: | |
deliveryContext: ${{ steps.deliveryContext.outputs.deliveryContext }} | |
with: | |
shell: powershell | |
type: 'CD' | |
projects: ${{ needs.Initialization.outputs.projects }} | |
deliveryTarget: ${{ matrix.deliveryTarget }} | |
artifacts: '.artifacts' | |
PostProcess: | |
if: (!cancelled()) | |
runs-on: [ windows-latest ] | |
needs: [ Initialization, Build, Deploy, Deliver ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Finalize the workflow | |
id: PostProcess | |
uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview | |
with: | |
shell: powershell | |
eventId: "DO0091" | |
telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} |