AL-Go
AL-Go copied to clipboard
Accessing GitHub Environment Variables in DeployToCustom Scenarios for PowerShell Scripts
Is there a way to make github environment variables accessible in DeployToCustom scenarios? In on OnPrem scenarios we need, insteaf of an AuthContext an Instance Name of Business Central to know the target of our deployment. I could misuse "AuthContext" but this doesn't look like a technical sound solution.
We have for example variables like "BC_Instance" that we need in "DeployToCustom.ps1" script to execute an deployment. I tried to find a way in the AL-Go Deploy.ps1 but did not find a viable way.
I assumed this code does the trick but unfortunately $env: is not the github environment in this context
$secrets = $env:Secrets | ConvertFrom-Json
(Line 29)
This is the point at which the custom script "DeployTo..." is called, unfortunately there is no option there either. So I currently have to call the environment variables in my own script via the GitHub API. This requires the repository ID (available), the environment name (available) and the GitHub workflow token. Unfortunately, the token is not available. Accordingly, this is not a viable option for me either. Do you have an approach for me here?
$customScript = Join-Path $ENV:GITHUB_WORKSPACE ".github/DeployTo$($deploymentSettings.EnvironmentType).ps1"
if (Test-Path $customScript) {
Write-Host "Executing custom deployment script $customScript"
$parameters = @{
"type" = $type
"AuthContext" = $authContext
"Apps" = $apps
} + $deploymentSettings
. $customScript -parameters $parameters
Suggestion: github environment variables are passed through to "DeployToCustom.ps1"
What environment variable do you need?
I'm trying to use different environments in the Repo pointing to the respective target I like to deploy to (the name of the NST).
@curateideas My Repository has two github environments (respectively also two AL-Go environments). Each of them has a variable with the name of the NST which I need access to.
We do have in our plans to make environment variables used as well - and I like the idea of adding that to the custom script.
In the meantime, the authcontext is a json structure, where you could add other properties as well as the actual authentication. AuthContext is already very much environment type specific - I would use that for now.
Is there already an approximate release date for the implementation?
On a similar note, would it be possible to trigger not only .ps1 files via AL-Go but also YAML files? This would make GitHub actions available and also the implementation of existing custom deployments workflows.
In GitHub, you wouldn't trigger a yaml file - what you do is that you create another yaml file and specify that it should be triggered if completion of CI/CD - and then you check in that workflow whether the CI/CD workflow successfully completed. You can do this today. At this time, I don't know when we will get to the above feature request.
Next version you will be able to add a custom property to your DeployTo setting, in which you can specify the name of the NST. So not as a variable under environments, but as a setting