Skip to content

Support repository custom properties in conditional settings - #2467

Open
Alex Richter (AlexanderRichter) wants to merge 7 commits into
microsoft:mainfrom
MODUS-TestALGO:alexanderrichter-conditional-custom-properties
Open

Alex Richter (AlexanderRichter) wants to merge 7 commits into
microsoft:mainfrom
MODUS-TestALGO:alexanderrichter-conditional-custom-properties

Conversation

@AlexanderRichter

@AlexanderRichter Alex Richter (AlexanderRichter) commented Nov 19, 2026 •

Copy link
Copy Markdown

❔What, Why & How

Allow AL-Go conditional settings to match GitHub repository custom properties. This lets organizations use centrally managed repository metadata to select settings without maintaining lists of repository names.

Motivation and use cases

Organizations can classify repositories centrally by build profile, business unit, or product area using GitHub Custom Properties. AL-Go should be able to use that classification directly in organization-wide settings (ALGoOrgSettings), instead of depending on repository naming conventions or duplicating configuration across repositories.

GitHub manages the property definitions and allows organizations to delegate maintenance of repository values. This feature only reads that metadata; it does not create or modify properties or require organization-administration permissions solely for this functionality.

Configuration examples

For example, enable analyzers only for repositories with the al-go-profile property set to strict, and only on the specified branches:

{
  "ConditionalSettings": [
    {
      "customProperties": {
        "al-go-profile": ["strict"]
      },
      "branches": ["main", "release/*"],
      "settings": {
        "enableCodeCop": true,
        "enableUICop": true
      }
    }
  ]
}

An organization can also select a versioning strategy by business unit, while retaining its normal default for repositories that match neither rule:

{
  "ConditionalSettings": [
    {
      "customProperties": {
        "BusinessUnit": ["INDUSTRY"]
      },
      "settings": {
        "versioningStrategy": 0
      }
    },
    {
      "customProperties": {
        "BusinessUnit": ["FOOD"]
      },
      "settings": {
        "versioningStrategy": 3
      }
    }
  ]
}

These are ordinary conditional settings overrides; existing merge order and overwriteSettings/protectedSettings behavior are retained. The versioning example applies to normal CI/CD runs; pull-request builds enforce their own versioning strategy.

Matching and implementation

The customProperties condition maps property names to arrays of allowed values. All properties and other conditions in a block must match; values for one property are alternatives. Matching is case-insensitive, supports wildcard patterns and multi-select values, and does not match missing or null values.

Property values are fetched on demand from the repository identified by GITHUB_REPOSITORY, using the GitHub API URL and an authenticated, read-only token. Results are cached per API host and repository for the PowerShell process. API and authentication failures are surfaced rather than silently treated as missing values. Action and telemetry settings reads receive a step-scoped token; local callers may also provide a property map.

The implementation extends the shared ReadSettings path and the settings schema, with corresponding action/token integration, unit tests, scenario documentation, and release notes. Repositories without applicable property conditions do not incur a property API request. Full owner/repository identity is retained for API requests while existing repository-name conditions continue using the short name.

Scope and governance

There is no general expression language, script evaluation, property-writing capability, or automatic workflow trigger when a property changes. The cache is process-scoped, not a workflow-wide snapshot: separate processes and reruns may see updated values.

Changing repository metadata can change pipeline behavior without changing a commit. Organizations should therefore control who can edit these values according to the importance of the affected settings. Custom Properties are not secrets and do not replace environment approvals, rulesets, or token permissions. Enterprise API availability and fork-PR permission combinations are not claimed as live-validated by the reported PTE test.

Compatibility: Older AL-Go versions ignore unknown conditions. Upgrade all repositories consuming central conditional settings before adding customProperties, otherwise those repositories may apply rules without the property restriction. This change also rejects unknown conditional keys rather than silently ignoring them; previously tolerated misspellings or unrecognized keys will now fail settings resolution. Property changes do not automatically regenerate materialized workflow settings such as schedules or concurrency.

Related to issue: MODUS-TestALGO#1

✅ Checklist

  • Add tests (E2E, unit tests)
  • Update RELEASENOTES.md
  • Update documentation (e.g. for new settings or scenarios)
  • Add telemetry

The existing action telemetry is preserved and authenticated when its settings depend on custom properties. No custom-property values or new telemetry dimensions are added.

Validation

  • Pester unit tests cover matching, missing values, validation, caching, host/repository isolation, API errors, action token wiring, and telemetry authentication.
  • pwsh -NoLogo -NoProfile -Command 'Import-Module Pester -RequiredVersion 5.7.1 -ErrorAction Stop; & .\Tests\runtests.ps1 -Path Tests': 1,098 passed, 0 failed on Windows/PowerShell 7 (started before the final token-isolation change).
  • Targeted TelemetryHelper.Test.ps1 and ReadSettings.Action.Test.ps1: 56 passed on each of Windows PowerShell 5.1 and PowerShell 7.
  • Fork CI on commit 409e05ceee340a452e17cd1ee249ca606d704c25: Windows PowerShell 5 and Linux PowerShell 7 unit tests passed; PSScriptAnalyzer passed.
  • A private PTE test repository was exercised with two custom-property values; CI/CD resolved versioning strategies 0 and 3, respectively.
  • A subsequent private PTE CI/CD run with the token-isolation change succeeded with telemetry enabled and no telemetry errors.
  • Full upstream E2E matrix: not run; Microsoft normally runs it during review.
  • pre-commit run --all-files in GitHub Codespaces: all applicable hooks passed, including Detect hardcoded secrets; sort simple yaml files had no files to check. Run output supplied by the contributor.
  • The fork's pre-commit GitHub Actions workflow reported startup_failure before any job started; its cause has not been confirmed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Provide the workflow token to actions that re-read settings internally, preserving explicit GITHUB_TOKEN overrides. Cover project analysis, build matrix resolution, and action token wiring.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Provide a step-scoped token for telemetry settings reads and preserve explicit overrides. Cover authenticated custom-property evaluation and all action wrapper steps.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Capture the step-scoped token in the telemetry module before invoking action code and verify that it is removed from the process environment.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 12:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The unconditional parent-directory helper import breaks both development-environment scripts in the flattened download layout, and custom-property lookups can succeed without valid authentication.

2 open issues
What changed in this PR

Adds repository custom-property conditions to AL-Go settings, allowing centrally managed GitHub metadata to select build, test, and deployment behavior.

Changes:

  • Adds property matching, on-demand API retrieval, caching, and condition validation.
  • Provides step-scoped authentication for settings reads and telemetry.
  • Updates the schema, documentation, release notes, and regression tests.
File Description
Tests/​TestActionsHelper.psm1 Supports token wiring assertions.
Tests/​TelemetryHelper.Test.ps1 Covers telemetry token isolation and authenticated settings reads.
Tests/​RunPipeline.Action.Test.ps1 Checks nested-settings token wiring.
Tests/​ReadSettings.Test.ps1 Covers property matching, validation, caching, and failures.
Tests/​ReadSettings.Action.Test.ps1 Checks token input fallback.
Tests/​IncrementVersionNumber.Action.Test.ps1 Checks nested-settings token wiring.
Tests/​DetermineProjectsToBuild.Test.ps1 Covers authenticated project analysis and build matrices.
Tests/​DetermineDeliveryTargets.Test.ps1 Checks nested-settings token wiring.
Tests/​DetermineArtifactsForRelease.Test.ps1 Checks nested-settings token wiring.
Tests/​Deliver.Action.Test.ps1 Checks nested-settings token wiring.
Tests/​CreateApp.Action.Test.ps1 Checks nested-settings token wiring.
Tests/​CheckForUpdates.Action.Test.ps1 Checks nested-settings token wiring.
Scenarios/​settings.md Documents matching, authentication, caching, and upgrade requirements.
RELEASENOTES.md Announces custom-property conditions and compatibility changes.
Actions/​WorkflowPostProcess/​action.yaml Supplies a telemetry token.
Actions/​WorkflowInitialize/​action.yaml Supplies a telemetry token.
Actions/​VerifyPRChanges/​action.yaml Supplies a telemetry token.
Actions/​ValidateWorkflowInput/​action.yaml Supplies a telemetry token.
Actions/​Troubleshooting/​action.yaml Supplies a telemetry token.
Actions/​TelemetryHelper.psm1 Captures the scoped token for telemetry settings reads.
Actions/​Sign/​action.yaml Supplies a telemetry token.
Actions/​SetupBCQuality/​action.yaml Supplies a telemetry token.
Actions/​RunTests/​action.yaml Supplies a telemetry token.
Actions/​RunPipeline/​action.yaml Supplies a token for nested settings reads.
Actions/​RunHook/​action.yaml Supplies a telemetry token.
Actions/​ReviewAgent/​action.yaml Supplies a telemetry token.
Actions/​ReadSettings/​ReadSettings.ps1 Passes the token to the settings resolver.
Actions/​ReadSettings/​README.md Documents token inputs and property retrieval.
Actions/​ReadSettings/​action.yaml Adds token input and fallback wiring.
Actions/​ReadSecrets/​action.yaml Supplies a telemetry token.
Actions/​ReadPowerPlatformSettings/​action.yaml Supplies a telemetry token.
Actions/​PullRequestStatusCheck/​action.yaml Supplies a telemetry token.
Actions/​PullPowerPlatformChanges/​action.yaml Supplies scoped tokens to action steps.
Actions/​ProcessALCodeAnalysisLogs/​action.yaml Supplies a telemetry token.
Actions/​PipelineCleanup/​action.yaml Supplies a telemetry token.
Actions/​IncrementVersionNumber/​action.yaml Supplies a token for nested settings reads.
Actions/​GetWorkflowMultiRunBranches/​action.yaml Supplies a telemetry token.
Actions/​GetArtifactsForDeployment/​action.yaml Supplies a telemetry token.
Actions/​DumpWorkflowInfo/​action.yaml Supplies a telemetry token.
Actions/​DownloadProjectDependencies/​action.yaml Supplies tokens for telemetry and nested settings reads.
Actions/​DownloadPreviousRelease/​action.yaml Supplies a telemetry token.
Actions/​DetermineProjectsToBuild/​action.yaml Authenticates nested project settings reads.
Actions/​DetermineDeploymentEnvironments/​action.yaml Supplies a telemetry token.
Actions/​DetermineDeliveryTargets/​action.yaml Supplies a token for nested settings reads.
Actions/​DetermineBuildProject/​action.yaml Supplies a telemetry token.
Actions/​DetermineArtifactUrl/​action.yaml Supplies a telemetry token.
Actions/​DetermineArtifactsForRelease/​action.yaml Supplies a token for nested settings reads.
Actions/​DeployPowerPlatform/​action.yaml Supplies scoped tokens to action steps.
Actions/​Deploy/​action.yaml Supplies a telemetry token.
Actions/​Deliver/​action.yaml Supplies a token for nested settings reads.
Actions/​CreateReleaseNotes/​action.yaml Supplies a telemetry token.
Actions/​CreateDevelopmentEnvironment/​action.yaml Supplies a telemetry token.
Actions/​CreateApp/​action.yaml Supplies a token for nested settings reads.
Actions/​CompileApps/​action.yaml Supplies a token for nested settings reads.
Actions/​CheckForUpdates/​action.yaml Authenticates settings reads during system-file updates.
Actions/​CalculateArtifactNames/​action.yaml Supplies a telemetry token.
Actions/​BuildReferenceDocumentation/​action.yaml Supplies a telemetry token.
Actions/​BuildPowerPlatform/​action.yaml Supplies a telemetry token.
Actions/​Authenticate/​action.yaml Supplies a telemetry token.
Actions/​AnalyzeTests/​action.yaml Supplies a telemetry token.
Actions/​AddExistingApp/​action.yaml Supplies a telemetry token.
Actions/​.Modules/​settings.schema.json Defines conditional-setting structures and property allowlists.
Actions/​.Modules/​ReadSettings.psm1 Implements property retrieval, caching, matching, and validation.

Review effort: Balanced

Comment thread Actions/.Modules/ReadSettings.psm1 Resolved
Comment thread Actions/.Modules/ReadSettings.psm1 Resolved
@AlexanderRichter
Alex Richter (AlexanderRichter) marked this pull request as draft November 19, 2026 12:33
Support flattened development-script downloads and disable anonymous fallback for authenticated property requests. Add regression tests for both layouts and authentication failure paths.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the repository custom-property settings change.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@AlexanderRichter
Alex Richter (AlexanderRichter) marked this pull request as ready for review November 19, 2026 13:58
@AlexanderRichter

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="MODUS Consult GmbH"

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants