Skip to content

Commit

Permalink
Applying conditional settings for PR Builds (microsoft#958)
Browse files Browse the repository at this point in the history
AL-GO doesn't apply conditional settings on PR Builds. In BCApps we have
the following conditional setting in the project settings

```
"buildModes": [ "Translated" ],
"ConditionalSettings": [
        {
            "branches": [
                "releases/*.[0-5]"
            ],
            "settings": {
                "buildModes": [ "Translated", "Strict"]
            }
        }
    ]
```

Yet when you see the PR builds, it doesn't build in StrictMode: 
https://github.com/microsoft/BCApps/actions/runs/8044365490

In ReadSettings we only apply conditional settings if the branchname
matches the pattern in the setting. The problem is that the branchName
is set to GITHUB_BASE_REF which for PR builds triggered by the
pull_request trigger is the merge branch (e.g. refs/heads/merge/123).
The branch pattern for the conditional setting will therefore never
match on PR Builds.
  • Loading branch information
aholstrup1 authored Mar 7, 2024
1 parent e9f4cc6 commit c05e541
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,11 @@ function ReadSettings {
[string] $repoSettingsVariableValue = "$ENV:ALGoRepoSettings"
)

# If the build is triggered by a pull request the refname will be the merge branch. To apply conditional settings we need to use the base branch
if (($env:GITHUB_EVENT_NAME -eq "pull_request") -and ($branchName -eq $ENV:GITHUB_REF_NAME)) {
$branchName = $env:GITHUB_BASE_REF
}

function GetSettingsObject {
Param(
[string] $path
Expand Down

0 comments on commit c05e541

Please sign in to comment.