Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Actions/.Modules/ReadSettings.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ function GetDefaultSettings
}
"fullBuildPatterns" = @()
"excludeEnvironments" = @()
"continuousDeployment" = $null
"alDoc" = [ordered]@{
"continuousDeployment" = $false
"deployToGitHubPages" = $true
Expand Down
4 changes: 4 additions & 0 deletions Actions/.Modules/settings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,10 @@
},
"description": "An array of environments to be excluded from the build. See https://aka.ms/ALGoSettings#excludeenvironments"
},
"continuousDeployment": {
"type": ["boolean", "null"],
"description": "Global default for continuous deployment. When set to false, disables automatic CD for all environments (overrides the name-based default, but not per-environment DeployTo<name>.ContinuousDeployment). Set to null or omit to fall back to per-environment name conventions. See https://aka.ms/ALGoSettings#continuousdeployment"
},
"alDoc": {
"type": "object",
"properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ else {
$ghEnvironment = $ghEnvironments | Where-Object { $_.name -eq $environmentName }
$deploymentSettings.BranchesFromPolicy = @(Get-BranchesFromPolicy -ghEnvironment $ghEnvironment)

# If continuousDeployment is not set per-environment, check for a global continuousDeployment setting
if ($null -eq $deploymentSettings.continuousDeployment -and $null -ne $settings.continuousDeployment) {
$deploymentSettings.continuousDeployment = $settings.continuousDeployment
}

# Include Environment if:
# - Type is not Continous Deployment
# - Environment is setup for Continuous Deployment (in settings)
Expand Down
1 change: 1 addition & 0 deletions Scenarios/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ The repository settings are only read from the repository settings file (.github
| <a id="enableTaskScheduler"></a>enableTaskScheduler | Setting enableTaskScheduler to true in your project setting file, causes the build container to be created with the Task Scheduler running. | false |
| <a id="useCompilerFolder"></a>useCompilerFolder | Setting useCompilerFolder to true causes your pipelines to use containerless compiling. Unless you also set **doNotPublishApps** to true, setting useCompilerFolder to true won't give you any performance advantage, since AL-Go for GitHub will still need to create a container in order to publish and test the apps. In the future, publishing and testing will be split from building and there will be other options for getting an instance of Business Central for publishing and testing. **Note** when using UseCompilerFolder you need to sign apps using the new signing mechanism described [here](../Scenarios/Codesigning.md). | false |
| <a id="excludeEnvironments"></a>excludeEnvironments | excludeEnvironments can be an array of GitHub Environments, which should be excluded from the list of environments considered for deployment. github-pages is automatically added to this array and cannot be used as environment for deployment of AL-Go for GitHub projects. | [ ] |
| <a id="continuousDeployment"></a>continuousDeployment | Global default for continuous deployment. When set, this overrides the per-environment default (which is based on environment name conventions), but is itself overridden by any per-environment **DeployTo\<environmentname>** setting with **ContinuousDeployment** specified. Set to **false** to disable automatic CD for all environments globally — for example in an organization settings variable — while still allowing manual deployment via the **Publish To Environment** workflow. Per-environment settings can then opt back in by setting **DeployTo\<environmentname>** with **ContinuousDeployment** = true. | (not set — falls back to per-environment name convention) |
| <a id="trustMicrosoftNuGetFeeds"></a>trustMicrosoftNuGetFeeds | Unless this setting is set to false, AL-Go for GitHub will trust the NuGet feeds provided by Microsoft. The feeds provided by Microsoft contains all Microsoft apps, all Microsoft symbols and symbols for all AppSource apps. | true |
| <a id="trustedNuGetFeeds"></a>trustedNuGetFeeds | trustedNuGetFeeds can be an array of NuGet feed specifications, which AL-Go for GitHub will use for dependency resolution. Every feed specification must include a URL property and can optionally include a few other properties:<br />**url** = The URL of the feed (examples: https://pkgs.dev.azure.com/myorg/apps/\_packaging/myrepo/nuget/v3/index.json or https://nuget.pkg.github.com/mygithuborg/index.json").<br />**authTokenSecret** = If the NuGet feed specified by URL is private, the authTokenSecret must be the name of a secret containing the authentication token with permissions to search and read packages from the NuGet feed.<br />**patterns** = AL-Go for GitHub will only trust packages, where the ID matches this pattern. Default is all packages (\*).<br />**fingerprints** = If specified, AL-Go for GitHub will only trust packages signed with a certificate with a fingerprint matching one of the fingerprints in this array. | [ ] |
| <a id="nuGetFeedSelectMode"></a>nuGetFeedSelectMode | Determines the select mode when finding Business Central app packages from NuGet feeds, based on the dependency version specified in app.json. Options are:<br/>- `Earliest` for earliest version of the package<br/>- `EarliestMatching` for earliest version of the package also compatible with the Business Central version used<br/>- `Exact` for the exact version of the package<br/>- `Latest` for the latest version of the package<br/>- `LatestMatching` for the latest version of the package also compatible with the Business Central version used. | LatestMatching |
Expand Down
66 changes: 66 additions & 0 deletions Tests/DetermineDeploymentEnvironments.Test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,70 @@ Describe "DetermineDeploymentEnvironments Action Test" {
$EnvironmentCount | Should -Be 0
$UnknownEnvironment | Should -Be 0
}

# Global continuousDeployment: false disables CD for all environments
It 'Test calling action directly - Global continuousDeployment=false disables CD for all environments' {
Mock InvokeWebRequest -ParameterFilter { $uri -like '*/environments' } -MockWith {
return @{"Content" = (ConvertTo-Json -Compress -Depth 99 -InputObject @{ "environments" = @( @{ "name" = "test"; "protection_rules" = @() }, @{ "name" = "another"; "protection_rules" = @() } ) })}
}

# Global continuousDeployment=false - no environments should be included in CD
$settings = @{ "type" = "PTE"; "runs-on" = "ubuntu-latest"; "shell" = "pwsh"; "environments" = @(); "excludeEnvironments" = @( 'github-pages' ); "continuousDeployment" = $false; "alDoc" = @{ "continuousDeployment" = $false; "deployToGitHubPages" = $false } }
$env:Settings = $settings | ConvertTo-Json -Compress
. (Join-Path $scriptRoot $scriptName) -getEnvironments '*' -type 'CD'
PassGeneratedOutput
$EnvironmentCount | Should -Be 0
}

# Global continuousDeployment: false does not affect Publish
It 'Test calling action directly - Global continuousDeployment=false does not affect Publish' {
Mock InvokeWebRequest -ParameterFilter { $uri -like '*/environments' } -MockWith {
return @{"Content" = (ConvertTo-Json -Compress -Depth 99 -InputObject @{ "environments" = @( @{ "name" = "test"; "protection_rules" = @() }, @{ "name" = "another"; "protection_rules" = @() } ) })}
}

# Global continuousDeployment=false - Publish should still include all environments
$settings = @{ "type" = "PTE"; "runs-on" = "ubuntu-latest"; "shell" = "pwsh"; "environments" = @(); "excludeEnvironments" = @( 'github-pages' ); "continuousDeployment" = $false; "alDoc" = @{ "continuousDeployment" = $false; "deployToGitHubPages" = $false } }
$env:Settings = $settings | ConvertTo-Json -Compress
. (Join-Path $scriptRoot $scriptName) -getEnvironments 'test' -type 'Publish'
PassGeneratedOutput
$EnvironmentCount | Should -Be 1
($EnvironmentsMatrixJson | ConvertFrom-Json | ConvertTo-HashTable -recurse).matrix.include.environment | Should -Contain "test"
}

# Per-environment setting overrides global continuousDeployment
It 'Test calling action directly - Per-environment continuousDeployment overrides global setting' {
Mock InvokeWebRequest -ParameterFilter { $uri -like '*/environments' } -MockWith {
return @{"Content" = (ConvertTo-Json -Compress -Depth 99 -InputObject @{ "environments" = @( @{ "name" = "test"; "protection_rules" = @() }, @{ "name" = "another"; "protection_rules" = @() } ) })}
}

# Global=false but test environment opts back in with per-env setting
$settings = @{
"type" = "PTE"; "runs-on" = "ubuntu-latest"; "shell" = "pwsh"; "environments" = @(); "excludeEnvironments" = @( 'github-pages' )
"continuousDeployment" = $false
"DeployToTest" = @{ "continuousDeployment" = $true }
"alDoc" = @{ "continuousDeployment" = $false; "deployToGitHubPages" = $false }
}
$env:Settings = $settings | ConvertTo-Json -Compress -Depth 5
. (Join-Path $scriptRoot $scriptName) -getEnvironments '*' -type 'CD'
PassGeneratedOutput
$EnvironmentCount | Should -Be 1
($EnvironmentsMatrixJson | ConvertFrom-Json | ConvertTo-HashTable -recurse).matrix.include.environment | Should -Contain "test"
($EnvironmentsMatrixJson | ConvertFrom-Json | ConvertTo-HashTable -recurse).matrix.include.environment | Should -Not -Contain "another"
}

# No global setting - existing name-based default behaviour is preserved
It 'Test calling action directly - No global continuousDeployment preserves existing name-based default' {
Mock InvokeWebRequest -ParameterFilter { $uri -like '*/environments' } -MockWith {
return @{"Content" = (ConvertTo-Json -Compress -Depth 99 -InputObject @{ "environments" = @( @{ "name" = "test (PROD)"; "protection_rules" = @() }, @{ "name" = "another"; "protection_rules" = @() } ) })}
}

# No global continuousDeployment - PROD-tagged environment excluded, non-PROD included (existing behaviour)
$settings = @{ "type" = "PTE"; "runs-on" = "ubuntu-latest"; "shell" = "pwsh"; "environments" = @(); "excludeEnvironments" = @( 'github-pages' ); "alDoc" = @{ "continuousDeployment" = $false; "deployToGitHubPages" = $false } }
$env:Settings = $settings | ConvertTo-Json -Compress
. (Join-Path $scriptRoot $scriptName) -getEnvironments '*' -type 'CD'
PassGeneratedOutput
$EnvironmentCount | Should -Be 1
($EnvironmentsMatrixJson | ConvertFrom-Json | ConvertTo-HashTable -recurse).matrix.include.environment | Should -Contain "another"
($EnvironmentsMatrixJson | ConvertFrom-Json | ConvertTo-HashTable -recurse).matrix.include.environment | Should -Not -Contain "test (PROD)"
}
}
Loading