Skip to content

DeployTo setting supported as environment variable #1702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 82 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
32b0ee6
Added env params to ReadSettings and logic to get DeployTo var from e…
spetersenms May 5, 2025
c26f52a
Added environmentName and environmentDeployToVariable value parms.
spetersenms May 5, 2025
27a2ab9
Added environmentName and environmentDeployToVariableValue params.
spetersenms May 5, 2025
a41820a
Passing new ReadSetting params in flows
spetersenms May 5, 2025
f5674c4
Precommit
spetersenms May 5, 2025
8df75d4
Adding token to ReadSettings action and passing to ReadSettings helper.
spetersenms May 6, 2025
23e0da8
Helper function to find deployment environment variables.
spetersenms May 6, 2025
053361f
Moving read deployment environment variable logic to DetermineDeploym…
spetersenms May 7, 2025
9647bf0
Merging DeployTo from settings file and env variable
spetersenms May 7, 2025
b0d2b95
Error handling
spetersenms May 7, 2025
401230d
Using ghTokenWorkflow for authenticating the variables api endpoint.
spetersenms May 8, 2025
3177598
Debug logs.
spetersenms May 8, 2025
afa11ce
Additional permissions for GITHUB_TOKEN
spetersenms May 8, 2025
e4f695f
Removed incorrect permission again.
spetersenms May 8, 2025
3a87b7b
Requesting needed permissions for api.
spetersenms May 8, 2025
3647d97
Updating permission param type to hashtable
spetersenms May 8, 2025
df0e312
Converting returned variable value from Json
spetersenms May 8, 2025
286680c
Converting to hashtable
spetersenms May 8, 2025
1599529
Removing debug logs
spetersenms May 8, 2025
dacf58b
Documentation updated.
spetersenms May 8, 2025
0728f17
Adjust deployment environment variable setting to take priority over …
spetersenms May 8, 2025
f6b5a31
Adding new param to app source yaml to match PTE flow.
spetersenms May 8, 2025
ba01203
pre-commit
spetersenms May 8, 2025
68fa02f
Mock variables api
spetersenms May 8, 2025
fa79500
Move url generation to try-catch for better error handling.
spetersenms May 8, 2025
449e009
Setting default value for ghTokenWorkflow to empty string.
spetersenms May 8, 2025
ff2175d
Adding test to verify that deployment environment variable takes prio…
spetersenms May 8, 2025
0f1fdde
Merge branch 'main' into DeployToEnvVar
spetersenms May 9, 2025
ed9c0aa
Merge branch 'DeployToEnvVar' of github.com:spetersenms/AL-Go into De…
spetersenms May 9, 2025
58f5538
Fixing missing variable in test.
spetersenms May 9, 2025
5f6d4b4
Passing ghTokenWorkflow to helper function.
spetersenms May 9, 2025
198e2b5
Debug comment removed.
spetersenms May 9, 2025
bbf6c54
Reverting changes to Init job.
spetersenms May 13, 2025
4332e5c
Printing warning if unsupported property is used in environment varia…
spetersenms May 15, 2025
dca4389
Reverting functionality to original state.
spetersenms May 19, 2025
1cc7766
Removed incorrect whitespace.
spetersenms May 19, 2025
aa2e709
Merge branch 'main' into DeployToEnvVar
spetersenms May 19, 2025
f59d583
Added back param accidentally removed while fixing conflict from merg…
spetersenms May 19, 2025
8998640
Reverting test changes.
spetersenms May 19, 2025
b0ba1f1
Added release notes.
spetersenms May 19, 2025
ae59ef9
Merge branch 'main' into DeployToEnvVar
spetersenms May 19, 2025
c166955
Merge branch 'main' into DeployToEnvVar
spetersenms Jun 16, 2025
fd1b9a4
Moved release notes.
spetersenms Jun 16, 2025
efbccd7
Merge branch 'main' into DeployToEnvVar
spetersenms Jun 16, 2025
c8aa5d1
Merge branch 'main' into DeployToEnvVar
spetersenms Jun 16, 2025
512eaf8
Merge branch 'main' into DeployToEnvVar
spetersenms Jun 17, 2025
e9cc5cd
Merge branch 'main' into DeployToEnvVar
spetersenms Jun 18, 2025
937cd81
Merge branch 'main' into DeployToEnvVar
spetersenms Jun 23, 2025
aeea15e
Readding logic accidentally removed during merge from main conflict h…
spetersenms Jun 23, 2025
e155e85
Using more generic name for environment settings, and testing use of …
spetersenms Jul 4, 2025
f5058b3
Moving env to step
spetersenms Jul 4, 2025
4349eaf
Trying to set env vars in new step.
spetersenms Jul 4, 2025
0cdd7a1
Corrected syntax.
spetersenms Jul 4, 2025
2e2b4fc
Compressing json.
spetersenms Jul 4, 2025
9b27b42
Forcing string type.
spetersenms Jul 4, 2025
055fd42
Single quotes instead of double
spetersenms Jul 4, 2025
0b38ecd
Using env variables instead of passing param.
spetersenms Jul 4, 2025
0eeec84
Removing all param passing of repo env variable and use passing as en…
spetersenms Jul 4, 2025
2dafad6
Merge branch 'main' into DeployToEnvVar
spetersenms Jul 7, 2025
4d94f33
Consistency across workflows.
spetersenms Jul 7, 2025
138fc2e
Aligning format of environment settings to be similar to org and repo…
spetersenms Jul 7, 2025
bfaf06f
Merge branch 'DeployToEnvVar' of github.com:spetersenms/AL-Go into De…
spetersenms Jul 7, 2025
a5649f6
Better formatting of warning.
spetersenms Jul 7, 2025
b63b47e
Typo.
spetersenms Jul 7, 2025
09c82fc
Using ALGoEnvironmentSettings instead of DeployTo for env setting var…
spetersenms Jul 7, 2025
af5af45
Removing debug comment.
spetersenms Jul 7, 2025
eb205b3
pre-commit
spetersenms Jul 7, 2025
c6323d7
Updated action readme.
spetersenms Jul 7, 2025
257ed70
Updated release notes.
spetersenms Jul 7, 2025
c982d24
pre-commit
spetersenms Jul 7, 2025
0cf6585
Fixed function documentation error.
spetersenms Jul 7, 2025
2376f12
Merge branch 'main' into DeployToEnvVar
spetersenms Jul 8, 2025
7cbf9a9
Adjusted release notes to fit more generic implementation.
spetersenms Jul 9, 2025
90fa6fb
Using OutputWarning.
spetersenms Jul 9, 2025
46b2b50
Merge branch 'DeployToEnvVar' of github.com:spetersenms/AL-Go into De…
spetersenms Jul 9, 2025
dc3dcce
Merge branch 'main' into DeployToEnvVar
spetersenms Jul 9, 2025
7eabca3
Using job env to set repo env var value
spetersenms Jul 10, 2025
efcaea2
Removed warning.
spetersenms Jul 14, 2025
3725574
Merge branch 'main' into DeployToEnvVar
spetersenms Jul 14, 2025
c74046d
Aligning workflows.
spetersenms Jul 14, 2025
8716c6e
Merge branch 'DeployToEnvVar' of github.com:spetersenms/AL-Go into De…
spetersenms Jul 14, 2025
3a5d393
Merge branch 'main' into DeployToEnvVar
spetersenms Jul 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Actions/.Modules/ReadSettings.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ function GetDefaultSettings
- .github/<workflowName>.settings.json = Workflow settings file
- <project>/.AL-Go/<workflowName>.settings.json = Project workflow settings file
- <project>/.AL-Go/<userName>.settings.json = User settings file
- ALGoEnvSettings (github Variable) = Deployment Environment settings variable
.PARAMETER baseFolder
The base folder where the settings files are located. Default is $ENV:GITHUB_WORKSPACE when running in GitHub Actions.
.PARAMETER repoName
Expand All @@ -255,6 +256,10 @@ function GetDefaultSettings
The value of the organization settings variable. Default is $ENV:ALGoOrgSettings.
.PARAMETER repoSettingsVariableValue
The value of the repository settings variable. Default is $ENV:ALGoRepoSettings.
.PARAMETER environmentSettingsVariableValue
The value of the current GitHub environment settings variable, based on workflow context. Default is $ENV:ALGoEnvSettings.
.PARAMETER environmentName
The value of the environment name, based on the workflow context. Default is $ENV:ALGoEnvName.
.PARAMETER silent
If specified, the function will not output any messages to the console.
#>
Expand All @@ -269,6 +274,8 @@ function ReadSettings {
[string] $branchName = "$ENV:GITHUB_REF_NAME",
[string] $orgSettingsVariableValue = "$ENV:ALGoOrgSettings",
[string] $repoSettingsVariableValue = "$ENV:ALGoRepoSettings",
[string] $environmentSettingsVariableValue = "$ENV:ALGoEnvSettings",
[string] $environmentName = "$ENV:ALGoEnvName",
[switch] $silent
)

Expand Down Expand Up @@ -353,6 +360,24 @@ function ReadSettings {
}
}

if ($environmentSettingsVariableValue) {
# Read settings from environment variable (parameter)
$environmentVariableObject = $environmentSettingsVariableValue | ConvertFrom-Json
# Warn user that 'DeployTo' setting needs to include environment name
if ($environmentVariableObject.PSObject.Properties.Name -contains "DeployTo") {
OutputWarning "The environment settings variable contains the property 'DeployTo'. Did you intend to use 'DeployTo$environmentName' instead? The 'DeployTo' property without a specific environment name is not supported."
}
# Warn user if 'runs-on', 'shell' or 'ContinuousDeployment' is defined in the environment settings variable, as these are not supported when defined there.
if ($environmentVariableObject.PSObject.Properties.Name -contains "DeployTo$environmentName") {
@('runs-on', 'shell', 'ContinuousDeployment') | ForEach-Object {
if ($environmentVariableObject."DeployTo$environmentName".PSObject.Properties.Name -contains $_) {
OutputWarning "The property $_ in the DeployTo setting is not supported when defined within a GitHub deployment environment variable. Please define this property elsewhere."
}
}
}
$settingsObjects += @($environmentVariableObject)
}

foreach($settingsJson in $settingsObjects) {
if ($settingsJson) {
MergeCustomObjectIntoOrderedDictionary -dst $settings -src $settingsJson
Expand Down
22 changes: 22 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

AL-Go now offers a dataexplorer dashboard to get started with AL-Go telemetry. Additionally, we've updated the documentation to include a couple of kusto queries if you would rather build your own reports.

### Support for AL-Go settings as GitHub environment variable: ALGoEnvSettings

AL-Go settings can now be defined in GitHub environment variables. To use this feature, create a new variable under your GitHub environment called `ALGoEnvironmentSettings`. Please note that this variable should not include your environment name.

Settings loaded this way, will only be available during the Deploy step of the CI/CD or Publish to Environment actions, but not the Build step, making it most suitable for the [DeployTo setting](https://aka.ms/algosettings#deployto). Settings defined in this variable will take priority over any setting defined in AL-Go repo, org or settings files.

The contents of the variable should be a JSON block, similar to any other settings file or variable. When defining the `DeployTo\<EnvName>` setting in this variable, it should still include the environment name. Eg:

```
{
DeployToProduction {
"Branches": [
"*"
],
"includeTestAppsInSandboxEnvironment": false,
"excludeAppIds": [ 1234 ]
}
}
```

Please note, that due to certain security limitations, the properties `runs-on`, `shell` and `ContinousDeployment` of the `DeployTo` setting will <ins>**NOT**</ins> be respected if defined in a GitHub environment variable. To use these properties, please keep them defined elsewhere, such as your AL-Go settings file or Org/Repo settings variables.

### Issues

- Issue 1770 Wrong type of _projects_ setting in settings schema
Expand Down
3 changes: 3 additions & 0 deletions Templates/AppSource App/.github/workflows/CICD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ jobs:
environment:
name: ${{ matrix.environment }}
url: ${{ steps.Deploy.outputs.environmentUrl }}
env:
ALGoEnvSettings: ${{ vars.ALGoEnvironmentSettings }}
ALGoEnvName: ${{ matrix.environment }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ jobs:
url: ${{ steps.Deploy.outputs.environmentUrl }}
env:
deviceCode: ${{ needs.Initialization.outputs.deviceCode }}
ALGoEnvSettings: ${{ vars.ALGoEnvironmentSettings }}
ALGoEnvName: ${{ matrix.environment }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand Down
3 changes: 3 additions & 0 deletions Templates/Per Tenant Extension/.github/workflows/CICD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ jobs:
environment:
name: ${{ matrix.environment }}
url: ${{ steps.Deploy.outputs.environmentUrl }}
env:
ALGoEnvSettings: ${{ vars.ALGoEnvironmentSettings }}
ALGoEnvName: ${{ matrix.environment }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ jobs:
url: ${{ steps.Deploy.outputs.environmentUrl }}
env:
deviceCode: ${{ needs.Initialization.outputs.deviceCode }}
ALGoEnvSettings: ${{ vars.ALGoEnvironmentSettings }}
ALGoEnvName: ${{ matrix.environment }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand Down
Loading