diff --git a/Actions/AL-Go-Helper.ps1 b/Actions/AL-Go-Helper.ps1 index 0ab8ddbdc..2f898d511 100644 --- a/Actions/AL-Go-Helper.ps1 +++ b/Actions/AL-Go-Helper.ps1 @@ -522,6 +522,7 @@ function ReadSettings { "environments" = @() "buildModes" = @() "useCompilerFolder" = $false + "PullRequestTrigger" = "pull_request_target" } # Read settings from files and merge them into the settings object diff --git a/Actions/CheckForUpdates/CheckForUpdates.ps1 b/Actions/CheckForUpdates/CheckForUpdates.ps1 index 523597892..d9f8909c0 100644 --- a/Actions/CheckForUpdates/CheckForUpdates.ps1 +++ b/Actions/CheckForUpdates/CheckForUpdates.ps1 @@ -220,16 +220,22 @@ try { } } - # The PullRequestHandler workflow can have a RepoSetting called CICDPullRequestBranches, which will be used to set the branches for the workflow if ($baseName -eq "PullRequestHandler") { + # The PullRequestHandler workflow can have a RepoSetting called PullRequestTrigger which specifies the trigger to use for Pull Requests + $triggerSection = $yaml.Get('on:/pull') + $triggerSection.content = "$($repoSettings.PullRequestTrigger):" + $yaml.Replace('on:/pull', $triggerSection.Content) + + # The PullRequestHandler workflow can have a RepoSetting called CICDPullRequestBranches, which will be used to set the branches for the workflow if ($repoSettings.Keys -contains 'CICDPullRequestBranches') { $CICDPullRequestBranches = $repoSettings.CICDPullRequestBranches } else { $CICDPullRequestBranches = $defaultCICDPullRequestBranches } + # update the branches: line with the new branches - $yaml.Replace('on:/pull_request_target:/branches:', "branches: [ '$($cicdPullRequestBranches -join "', '")' ]") + $yaml.Replace("on:/$($repoSettings.PullRequestTrigger):/branches:", "branches: [ '$($CICDPullRequestBranches -join "', '")' ]") } # Repo Setting runs-on and shell determines which GitHub runner is used for all non-build jobs (build jobs are run using the GitHubRunner/GitHubRunnerShell repo settings) diff --git a/Actions/DetermineArtifactUrl/DetermineArtifactUrl.ps1 b/Actions/DetermineArtifactUrl/DetermineArtifactUrl.ps1 index 2f91c7a79..933a928f5 100644 --- a/Actions/DetermineArtifactUrl/DetermineArtifactUrl.ps1 +++ b/Actions/DetermineArtifactUrl/DetermineArtifactUrl.ps1 @@ -23,7 +23,11 @@ try { #region Action: Determine artifacts to use $telemetryScope = CreateScope -eventId 'DO0084' -parentTelemetryScopeJson $parentTelemetryScopeJson $secrets = $secretsJson | ConvertFrom-Json | ConvertTo-HashTable - $insiderSasToken = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($secrets.insiderSasToken)) + if ($secrets.ContainsKey('insiderSasToken')) { + $insiderSasToken = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($secrets.insiderSasToken)) + } else { + $insiderSasToken = "" + } $projectSettings = $env:Settings | ConvertFrom-Json | ConvertTo-HashTable $projectSettings = AnalyzeRepo -settings $projectSettings -project $project -doNotCheckArtifactSetting -doNotIssueWarnings $artifactUrl = Determine-ArtifactUrl -projectSettings $projectSettings -insiderSasToken $insiderSasToken diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 485c0b7be..9a3dbc2ea 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -25,6 +25,7 @@ Now, you can set the checkbox called Use GhTokenWorkflow to allowing you to use ### New Settings - `keyVaultCodesignCertificateName`: With this setting you can delegate the codesigning to an Azure Key Vault. This can be useful if your certificate has to be stored in a Hardware Security Module +- `PullRequestTrigger`: With this setting you can set which trigger to use for Pull Request Builds. By default AL-Go will use pull_request_target. ### New Actions - `DownloadProjectDependencies`: Downloads the dependency apps for a given project and build mode. diff --git a/Scenarios/settings.md b/Scenarios/settings.md index 47c35f78e..954ec2759 100644 --- a/Scenarios/settings.md +++ b/Scenarios/settings.md @@ -53,6 +53,7 @@ The repository settings are only read from the repository settings file (.github | useProjectDependencies | Determines whether your projects are built using a multi-stage built workflow or single stage. After setting useProjectDependencies to true, you need to run Update AL-Go System Files and your workflows including a build job will change to have multiple build jobs, depending on each other. The number of build jobs will be determined by the dependency depth in your projects.
You can change dependencies between your projects, but if the dependency **depth** changes, AL-Go will warn you that updates for your AL-Go System Files are available and you will need to run the workflow. | | CICDPushBranches | CICDPushBranches can be specified as an array of branches, which triggers a CI/CD workflow on commit.
Default is [ "main", "release/\*", "feature/\*" ] | | CICDPullRequestBranches | CICDPullRequestBranches can be specified as an array of branches, which triggers a CI/CD workflow on a PR.
Default is [ "main" ] | +| PullRequestTrigger | Setting for specifying the trigger AL-Go should use to trigger Pull Request Builds. By default it is set to [pull_request_target](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target) | | CICDSchedule | CRON schedule for when CI/CD workflow should run. Default is no scheduled run, only manually triggered or triggered by Push or Pull Request. Build your CRON string here: [https://crontab.guru](https://crontab.guru) | | UpdateGitHubGoSystemFilesSchedule | CRON schedule for when Update AL-Go System Files should run. When Update AL-Go System Files runs on a schedule, it uses direct COMMIT instead of creating a PR. Default is no scheduled run, only manual trigger. Build your CRON string here: [https://crontab.guru](https://crontab.guru) | | buildModes | A list of build modes to use when building the AL-Go projects. Every AL-Go projects will be built using each built mode. Available build modes are:
**Default**: Apps are compiled as they are in the source code.
**Clean**: _PreprocessorSymbols_ are enabled when compiling the apps. The values for the symbols correspond to the `cleanModePreprocessorSymbols` setting of the AL-Go project.
**Translated**: `TranslationFile` compiler feature is enabled when compiling the apps. | diff --git a/Templates/AppSource App/.github/workflows/PullRequestHandler.yaml b/Templates/AppSource App/.github/workflows/PullRequestHandler.yaml index 2f07b2c8e..7320f1f40 100644 --- a/Templates/AppSource App/.github/workflows/PullRequestHandler.yaml +++ b/Templates/AppSource App/.github/workflows/PullRequestHandler.yaml @@ -26,7 +26,7 @@ env: jobs: PregateCheck: - if: github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name + if: (github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name) && (github.event_name != 'pull_request') runs-on: [ windows-latest ] steps: - uses: actions/checkout@v3 diff --git a/Templates/AppSource App/.github/workflows/_BuildALGoProject.yaml b/Templates/AppSource App/.github/workflows/_BuildALGoProject.yaml index ad8201b83..962c01bb3 100644 --- a/Templates/AppSource App/.github/workflows/_BuildALGoProject.yaml +++ b/Templates/AppSource App/.github/workflows/_BuildALGoProject.yaml @@ -86,6 +86,7 @@ jobs: get: useCompilerFolder,keyVaultCodesignCertificateName,doNotSignApps - name: Read secrets + if: github.event_name != 'pull_request' uses: microsoft/AL-Go-Actions/ReadSecrets@main env: secrets: ${{ toJson(secrets) }} diff --git a/Templates/Per Tenant Extension/.github/workflows/PullRequestHandler.yaml b/Templates/Per Tenant Extension/.github/workflows/PullRequestHandler.yaml index 2f07b2c8e..7320f1f40 100644 --- a/Templates/Per Tenant Extension/.github/workflows/PullRequestHandler.yaml +++ b/Templates/Per Tenant Extension/.github/workflows/PullRequestHandler.yaml @@ -26,7 +26,7 @@ env: jobs: PregateCheck: - if: github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name + if: (github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name) && (github.event_name != 'pull_request') runs-on: [ windows-latest ] steps: - uses: actions/checkout@v3 diff --git a/Templates/Per Tenant Extension/.github/workflows/_BuildALGoProject.yaml b/Templates/Per Tenant Extension/.github/workflows/_BuildALGoProject.yaml index ad8201b83..962c01bb3 100644 --- a/Templates/Per Tenant Extension/.github/workflows/_BuildALGoProject.yaml +++ b/Templates/Per Tenant Extension/.github/workflows/_BuildALGoProject.yaml @@ -86,6 +86,7 @@ jobs: get: useCompilerFolder,keyVaultCodesignCertificateName,doNotSignApps - name: Read secrets + if: github.event_name != 'pull_request' uses: microsoft/AL-Go-Actions/ReadSecrets@main env: secrets: ${{ toJson(secrets) }}