Enable AL-Go for GitHub on GitHub Enterprise Cloud with data residency - #2309
Enable AL-Go for GitHub on GitHub Enterprise Cloud with data residency#2309freddydk wants to merge 24 commits into
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Enables AL-Go templates and actions to operate on GitHub Enterprise Cloud data-residency hosts.
Changes:
- Replaces hardcoded GitHub URLs with runtime server/API URLs.
- Updates release uploads, dependency retrieval, and template downloads for enterprise hosts.
- Adds enterprise documentation, release notes, safeguards, and regression fixes.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
Tests/DownloadProjectDependencies.Test.ps1 |
Tests URL secrets. |
Tests/Deploy.Module.Test.ps1 |
Configures API URL in tests. |
Templates/Per Tenant Extension/.github/workflows/CreateRelease.yaml |
Makes release operations host-aware. |
Templates/Per Tenant Extension/.AL-Go/localDevEnv.ps1 |
Clarifies GitHub CLI authentication. |
Templates/AppSource App/.github/workflows/CreateRelease.yaml |
Makes release operations host-aware. |
Templates/AppSource App/.AL-Go/localDevEnv.ps1 |
Clarifies GitHub CLI authentication. |
Scenarios/UsingGitHubEnterprise.md |
Adds enterprise setup guidance. |
RELEASENOTES.md |
Announces enterprise compatibility. |
README.md |
Links the enterprise guide. |
Actions/WorkflowPostProcess/WorkflowPostProcess.ps1 |
Targets the active GitHub CLI host. |
Actions/VerifyPRChanges/VerifyPRChanges.ps1 |
Uses the runtime API URL. |
Actions/PullRequestStatusCheck/PullRequestStatusCheck.ps1 |
Targets the runtime GitHub host. |
Actions/Github-Helper.psm1 |
Derives dependency API hosts. |
Actions/GetArtifactsForDeployment/GetArtifactsForDeployment.psm1 |
Uses host-aware API and run URLs. |
Actions/GetArtifactsForDeployment/GetArtifactsForDeployment.ps1 |
Produces host-aware links. |
Actions/DownloadProjectDependencies/DownloadProjectDependencies.psm1 |
Resolves whole-URL secrets. |
Actions/DetermineProjectsToBuild/DetermineProjectsToBuild.psm1 |
Initializes empty project metadata. |
Actions/DetermineProjectsToBuild/DetermineProjectsToBuild.Action.ps1 |
Emits host-aware build links. |
Actions/Deploy/Deploy.psm1 |
Uses the runtime API URL. |
Actions/Deliver/Deliver.ps1 |
Handles package lookup failures. |
Actions/CheckForUpdates/CheckForUpdates.ps1 |
Configures the GitHub CLI host. |
Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 |
Adds host-aware template downloads. |
Actions/AL-Go-Helper.ps1 |
Updates defaults and dependency URLs. |
.github/workflows/CI.yaml |
Restricts AL-Go development CI to GitHub.com. |
| [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'defaultCICDPullRequestBranches', Justification = 'False positive.')] | ||
| $defaultCICDPullRequestBranches = @( 'main' ) | ||
| $defaultBcContainerHelperVersion = "preview" | ||
| $defaultBcContainerHelperVersion = "https://github.com/Freddy-DK/navcontainerhelper/archive/refs/heads/main.zip" |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 24 out of 24 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (6)
Actions/Deliver/Deliver.ps1:273
Find-BcNuGetPackagealready returns an empty result when no exact package exists. Catching every exception here also converts authentication, configuration, and feed-outage failures into “package missing,” after which the action attempts a push. That can publish after an inconclusive existence check and hides the original failure. Let unexpected lookup errors propagate.
try {
$feed, $packageId, $packageVersion = Find-BcNugetPackage -nuGetServerUrl $nuGetServerUrl -nuGetToken $nuGetToken -packageName $packageName -version $searchVersion -select Exact -allowPrerelease
}
catch {
$feed = $null
}
Scenarios/UsingGitHubEnterprise.md:30
- The documented authentication host differs from the data-residency destination (
<enterprise>.ghe.com) used in step 4. Following these commands authenticates GitHub CLI togithub.mycompany.com, so credentials will not be available for the actual destination. Use one consistent data-residency hostname throughout the example.
Replace `OWNER/REPO` with the public template (for example `microsoft/AL-Go-PTE` or `microsoft/AL-Go-AppSource`), and `ORG/REPO` and `github.mycompany.com` with your enterprise organization, repository name and host:
```pwsh
# 1. Authenticate to your enterprise host (if not already)
gh auth login --hostname github.mycompany.com
Scenarios/UsingGitHubEnterprise.md:36
GH_HOSTmust match the<enterprise>.ghe.comhost used by the subsequent mirror push. As written,gh repo createtargets a different host from the repository receiving the push.
$env:GH_HOST = "github.mycompany.com"
Scenarios/UsingGitHubEnterprise.md:87
- These commands seed the recommended enterprise templates from
Freddy-DK/*, contradicting the officialmicrosoft/AL-Go-PTEandmicrosoft/AL-Go-AppSourcesources identified above and used in the automated example. Users following this section would copy different repositories than the guide promises.
algoctl createrepo --repo https://<enterprise>.ghe.com/<org>/<enterprise>-PTE --templaterepo Freddy-DK/AL-Go-PTE
algoctl createrepo --repo https://<enterprise>.ghe.com/<org>/<enterprise>-AppSource --templaterepo Freddy-DK/AL-Go-AppSource
Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:101
- This bypasses the repository's
InvokeWebRequestwrapper, which handles rate-limit resets, moved repositories, and authentication fallback (Actions/Github-Helper.psm1:57-123). Consequently, Update AL-Go System Files now fails immediately in those cases only when resolving the latest template SHA. Keep using the wrapper with the dynamically constructed URL.
$url = "$apiUrl/branches/$branch"
Write-Host "Api URL: $url"
$result = Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri $url
$branchInfo = $result.Content | ConvertFrom-Json
Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:29
- The new host-dependent API URL and authentication branches are not covered by the existing CheckForUpdates Pester suite. Add unit tests for a public
github.comtemplate from a GHE workflow and a same-host<enterprise>.ghe.comtemplate, asserting the API URL and whether authentication is applied; these are the core compatibility paths introduced by this PR.
if ($templateUrl -like 'https://github.com/*') {
# templateUrl is github.com - use the github.com API URL
$apiUrl = $templateUrl.Split('@')[0] -replace "^($([regex]::Escape('https://github.com') -replace '/', '\/'))/(.*)$", "https://api.github.com/repos/`$2"
}
else {
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:100
- Calling the raw cmdlet here bypasses the repository's
InvokeWebRequestwrapper, which handles rate-limit resets, moved repositories, and retrying public resources without invalid authentication. This is especially relevant now that GHE workflows fetch public GitHub templates anonymously and can hit the low unauthenticated rate limit.
$result = Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri $url
Scenarios/UsingGitHubEnterprise.md:102
- Use the verb phrase “set up” here; “setup” is a noun or adjective.
If you used the automated approach and specified your indirect template as your template repo, the indirect template is already setup as your template repository.
|
@freddydk please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
Actions/Github-Helper.psm1:208
- The existing
GetDependenciestest only coversrelease_status = 'thisBuild', so it never executes this new host-derived API path. Add Pester cases forgithub.comand*.ghe.comdependencies that assert token acquisition and artifact/release requests receive the expected API URL; this is the core compatibility behavior introduced here.
$token = GetAccessToken -token $dependency.authTokenSecret -api_url $dependencyApiUrl -repository $repository -permissions @{"contents"="read";"actions"="read";"metadata"="read"}
$artifacts = GetArtifacts -token $token -api_url $dependencyApiUrl -repository $repository -mask $currentMask -projects $projects -version $dependency.version -branch $dependency.branch -baselineWorkflowID $dependency.baselineWorkflowID
Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1:31
Tests/CheckForUpdates.Action.Test.ps1does not invokeDownloadTemplateRepository, leaving both new URL branches untested. Add Pester coverage that verifies publicgithub.comtemplates useapi.github.com, same-host GHE templates useGITHUB_API_URL, and cross-host public downloads remain anonymous.
else {
# templateUrl is not github.com (e.g. github enterprise) - use the GITHUB_SERVER_URL and GITHUB_API_URL environment variables
$apiUrl = $templateUrl.Split('@')[0] -replace "^($([regex]::Escape($env:GITHUB_SERVER_URL) -replace '/', '\/'))/(.*)$", "$ENV:GITHUB_API_URL/repos/`$2"
| $dependencyUri = [uri]$dependency.repo | ||
| $dependencyApiUrl = "$($dependencyUri.Scheme)://api.$($dependencyUri.Host)" |
❔What, Why & How
This pull request introduces comprehensive updates to improve compatibility with GitHub Enterprise (GHE) hosts. The main focus is to ensure that all scripts and workflows dynamically use the correct GitHub server and API URLs, rather than hardcoding references to
github.comandapi.github.com. This enables repositories using AL-Go for GitHub to work seamlessly on both public GitHub and GHE instances. Additionally, documentation has been updated to clarify support and provide guidance for GHE users.GitHub Enterprise compatibility and dynamic host resolution:
GITHUB_SERVER_URLandGITHUB_API_URLenvironment variables instead of hardcodedgithub.comandapi.github.comURLs for REST API calls and repository links. This affects actions such as dependency probing, deployments, pull request validation, and workflow post-processing. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]github.com, preventing unsupported usage on GHE for the main repo.ghCLI commands set theGH_HOSTenvironment variable to ensure API calls target the correct host on GHE. [1] [2] [3]Documentation and user guidance:
Scenarios/UsingGitHubEnterprise.md, detailing how to use AL-Go for GitHub on GHE, including setup instructions and best practices.README.mdis updated to reference the new GHE usage guide.Other improvements and fixes:
These changes ensure that AL-Go for GitHub works reliably in both public and enterprise GitHub environments, with clear documentation and robust host detection.
This functionality was sponsored by Fellowmind, Sweden.