Repository navigation
Issue 2336 - Option to fail deployment - #2385
Thomas Rønn (thomasroennTRM) wants to merge 36 commits into
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Settings resolution, environment targeting, and artifact selection can diverge from the actual deployment and cause false passes or failures.
Review effort: Balanced
Findings: 4
Open (6)
What changed in this PR
Adds an opt-in safeguard that blocks CI/CD deployments when artifact app versions are lower than installed versions.
Changes:
- Adds the
CheckDowngradeaction and unit tests. - Integrates downgrade validation into PTE and AppSource workflows.
- Documents and registers the new setting.
| File | Description |
|---|---|
Actions/CheckDowngrade/CheckDowngrade.ps1 |
Implements downgrade detection. |
Actions/CheckDowngrade/action.yaml |
Defines the composite action. |
Actions/CheckDowngrade/README.md |
Documents action usage. |
Tests/CheckDowngrade.Action.Test.ps1 |
Tests core action behavior. |
Templates/Per Tenant Extension/.github/workflows/CICD.yaml |
Adds PTE pre-deployment validation. |
Templates/AppSource App/.github/workflows/CICD.yaml |
Adds AppSource pre-deployment validation. |
Actions/.Modules/ReadSettings.psm1 |
Adds the default setting. |
Actions/.Modules/settings.schema.json |
Defines global schema metadata. |
Scenarios/settings.md |
Documents global and environment settings. |
RELEASENOTES.md |
Announces the new action. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ripts and update documentation accordingly
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The check can fail environments that the existing deployment action intentionally skips, and the documented settings sources are inaccurate.
Review effort: Balanced
Findings: 1
Open (2)
Resolved since last review (2)
…d update tests accordingly
…support device code and improve error messaging
|
Thomas Rønn (@thomasroennTRM) Sorry for the delay in response. I can see there are a couple of PSScriptanalyzer findings we need to address before merging this, as well as one more comment from copilot. I think the new action you made it just missing on the Publish To Environment workflow as well :) |
There was a problem hiding this comment.
🟡 Changes recommended
The preflight consumes single-use device-login codes before Deploy can authenticate and rejects environments Deploy would skip, while affected tests expect too few validation calls.
2 open issues
1 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
The downgrade preflight checks production environments that Deploy intentionally skips, causing workflows to fail for targets that would not receive a deployment.
1 open issue
2 resolved since last review
Review effort: Balanced
Clarified the behavior of the new `CheckDowngrade` action regarding version checks and deployment processes. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The downgrade precheck omits Deploy’s production-environment skip rules, so environments that will not receive a deployment can incorrectly fail the job when an installed app is newer.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
… the multiline AuthContext before masking it.
There was a problem hiding this comment.
🔵 Needs a closer look
The downgrade preflight omits Deploy.ps1’s production eligibility guards, so deployments that should be skipped can instead fail the workflow during version checks.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
| return $false | ||
| } |
| Mock CheckInstalledApps { $script:checkBeforePublish = -not $script:publishCalled } | ||
| Mock Publish-PerTenantExtensionApps { $script:publishCalled = $true } | ||
| Mock Publish-BcContainerApp { $script:publishCalled = $true } |
| $installedApps = Get-BcInstalledExtensions -bcAuthContext $bcAuthContext -environment $deploymentSettings.EnvironmentName | | ||
| Where-Object { $_.isInstalled } |



❔What, Why & How
What
Adds an opt-in setting, failOnAppVersionDowngrade (default false). When it's enabled, the CI/CD deployment fails if an app in the build artifact has a lower version than the app already installed in the environment.
You can set it globally or per environment in DeployTo. The environment value takes precedence.
A new CheckDowngrade action runs before Deploy to Business Central in the PTE and AppSource App CI/CD workflows.
Why
Today, a deployment where the artifact version is lower than the installed version only produces a warning. The workflow still succeeds, so it's easy to miss that the apps were never updated. This setting lets you make that case fail the workflow.
How
The CI/CD workflow works out the effective setting for the environment.
If the setting is true, CheckDowngrade compares each app in the artifact with the installed version in the environment.
If any app would be downgraded, it writes one error per app and fails the deploy job.
Related to issue: #2336
#2336
✅ Checklist