Skip to content

Add support for custom templates + customizations #853

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

Merged
merged 282 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from 175 commits
Commits
Show all changes
282 commits
Select commit Hold shift + click to select a range
bcc2f3e
add permissions
freddydk Jul 25, 2024
2c62b84
add
freddydk Jul 25, 2024
496db91
add
freddydk Jul 25, 2024
4445277
dumps
freddydk Jul 25, 2024
7ef5d3d
add merge
freddydk Jul 25, 2024
6e8b95c
merge
freddydk Jul 25, 2024
422386d
use pso
freddydk Jul 25, 2024
40e20fd
use prop
freddydk Jul 25, 2024
846626e
test
freddydk Jul 25, 2024
82361a8
no idx
freddydk Jul 25, 2024
0936282
no idx
freddydk Jul 25, 2024
b156693
lower case
freddydk Jul 25, 2024
af146b7
add permissions
freddydk Jul 25, 2024
b9219b7
updates
freddydk Jul 27, 2024
dd36934
content parameter
freddydk Jul 27, 2024
f6c2dfb
use str
freddydk Jul 27, 2024
2992605
fix needs
freddydk Jul 27, 2024
b3534d5
add end 2 end test scenario and unit tests
freddydk Jul 30, 2024
5f34aed
precommit
freddydk Jul 30, 2024
99fb554
Merge branch 'main' into customize
freddydk Aug 5, 2024
418d259
Merge branch 'main' into customize
freddydk Aug 7, 2024
f19dda6
add pipeline init and finalize
freddydk Aug 7, 2024
a2e7b2b
support cicdauthcontext
freddydk Aug 8, 2024
91041b1
env name
freddydk Aug 8, 2024
492cfb5
dump
freddydk Aug 8, 2024
699ff4d
remove dump
freddydk Aug 9, 2024
260c2f3
Merge branch 'main' into customize
freddydk Aug 9, 2024
b2e47b1
fix tests
freddydk Aug 9, 2024
563c22f
Merge branch 'customize' of https://github.com/freddydk/AL-Go into cu…
freddydk Aug 9, 2024
1cc3a94
fix aldoc if
freddydk Aug 11, 2024
b48f675
Replace template owner
freddydk Aug 11, 2024
7c986d9
remove jekyll
freddydk Aug 11, 2024
39023cf
modify readme
freddydk Aug 11, 2024
0c69b29
dump readme
freddydk Aug 11, 2024
821aa81
dump
freddydk Aug 11, 2024
525048b
replace
freddydk Aug 11, 2024
1066788
merge if permissions are present
freddydk Aug 13, 2024
8258572
check
freddydk Aug 13, 2024
32e7f1b
check not ''
freddydk Aug 13, 2024
ddd95b1
add dump
freddydk Aug 13, 2024
96818d7
remove unused files not present in template
freddydk Aug 13, 2024
c97f705
move unused check
freddydk Aug 13, 2024
01b6d49
add customALGoSystemFiles
freddydk Aug 18, 2024
c43ea9a
Apply custom files
freddydk Aug 19, 2024
fd03c25
add to updates files
freddydk Aug 19, 2024
9ac3f24
relative
freddydk Aug 19, 2024
362ec0f
remove path
freddydk Aug 19, 2024
977f94b
do not dump custom algo system files
freddydk Aug 19, 2024
4ccfc85
compare
freddydk Aug 19, 2024
48cd019
define existing
freddydk Aug 19, 2024
5b70630
dump modified files
freddydk Aug 19, 2024
f83caa2
syntax
freddydk Aug 19, 2024
7646df4
use basefolder
freddydk Aug 19, 2024
c23d28c
doc
freddydk Aug 19, 2024
c7c49d8
upd
freddydk Aug 19, 2024
f8a1310
update custom and unused algo system files
freddydk Aug 22, 2024
4317c17
Support private template repo
freddydk Aug 22, 2024
57acb7c
use ghtokenworkflow
freddydk Aug 22, 2024
5573506
dump content
freddydk Aug 22, 2024
3ec676b
only update changed settings files
freddydk Aug 22, 2024
0d39e96
decode
freddydk Aug 22, 2024
3451a4a
indirect
freddydk Aug 22, 2024
37b7ecb
insert
freddydk Aug 22, 2024
78fb7a8
Merge branch 'main' into customize
freddydk Aug 22, 2024
dccb8e4
remove jekyll
freddydk Aug 22, 2024
6b51661
Merge branch 'customize' of https://github.com/freddydk/AL-Go into cu…
freddydk Aug 22, 2024
570628a
revert
freddydk Aug 22, 2024
e599e38
update
freddydk Aug 22, 2024
5cc070b
update release notes
freddydk Aug 22, 2024
cde82c9
rev
freddydk Aug 22, 2024
3decba8
Merge branch 'main' into customize
freddydk Aug 22, 2024
d60be05
psa
freddydk Aug 22, 2024
a1a2a6b
Merge branch 'customize' of https://github.com/freddydk/AL-Go into cu…
freddydk Aug 22, 2024
fa4a71b
remove
freddydk Aug 22, 2024
6685835
move
freddydk Aug 22, 2024
99265e6
remove fake button
freddydk Aug 22, 2024
0969502
use preview
freddydk Aug 22, 2024
a2dbcfd
precommit
freddydk Aug 22, 2024
a01e57a
dump token length
freddydk Aug 22, 2024
46da82c
add ghTokenWorkflow parameter
freddydk Aug 22, 2024
fa5a2d4
add ght
freddydk Aug 22, 2024
5c40c15
use token
freddydk Aug 22, 2024
000ae79
dump with token is used
freddydk Aug 22, 2024
26149de
check if permissions
freddydk Aug 22, 2024
51d5da5
Merge branch 'main' into customize
freddydk Aug 26, 2024
2457a21
Merge branch 'main' into customize
freddydk Aug 27, 2024
0e6e7c3
Update Scenarios/CustomizingALGoForGitHub.md
freddydk Sep 2, 2024
858865e
Update Scenarios/CustomizingALGoForGitHub.md
freddydk Sep 2, 2024
114bdc3
Merge branch 'main' into customize
freddydk Sep 3, 2024
f252f29
empty line
freddydk Sep 3, 2024
2e7722a
Update Scenarios/CustomizingALGoForGitHub.md
freddydk Sep 9, 2024
a76dc7d
Update Scenarios/settings.md
freddydk Sep 9, 2024
ab27cdb
Merge branch 'main' into customize
freddydk Sep 9, 2024
ddef716
prop
freddydk Sep 13, 2024
2ca9c43
merge
freddydk Oct 13, 2024
dc4580f
merge
freddydk Oct 13, 2024
1e857e3
Merge branch 'main' into customize
freddydk Oct 13, 2024
2cf539e
remove
freddydk Oct 29, 2024
5e06f58
Merge branch 'main' into customize
freddydk Oct 29, 2024
3ad4cbe
feat: add needsContext as env to build process (#206)
PatrickSchiefer Oct 29, 2024
1355bca
modify default
freddydk Oct 29, 2024
3fa79d6
feat: add needContext to Build job (#208)
PatrickSchiefer Oct 29, 2024
72c3749
Merge branch 'main' into customize
freddydk Nov 1, 2024
c5762f7
Merge branch 'main' into customize
freddydk Nov 1, 2024
23561ca
Merge branch 'main' into customize
freddydk Dec 10, 2024
ce76955
Merge branch 'main' into customize
freddydk Dec 16, 2024
d2b9fa9
Merge branch 'main' into customize
freddydk Dec 18, 2024
bbd9cd2
move
freddydk Dec 18, 2024
11a3f67
or
freddydk Dec 25, 2024
997dfdc
Merge branch 'main' into customize
freddydk Dec 30, 2024
70e2b61
Merge branch 'main' into customize
freddydk Dec 30, 2024
99d01c6
Merge branch 'main' into customize
freddydk Jan 11, 2025
d529538
precommit
freddydk Jan 11, 2025
38fd7bf
precommit
freddydk Jan 11, 2025
1ccecc8
Merge branch 'main' into customize
freddydk Jan 29, 2025
969e23b
fix: existing custom jobs are dropped during updates, don't duplicate…
ps610 Jan 30, 2025
788f20c
Merge branch 'main' into customize
freddydk Feb 25, 2025
68d82c6
Merge branch 'main' into customize
freddydk Feb 26, 2025
d2ee631
Merge branch 'main' into customize
freddydk Feb 27, 2025
12a4e9b
Merge branch 'main' into customize
freddydk Mar 2, 2025
4329866
remove githubtoken
freddydk Mar 3, 2025
78d6a2f
one token
freddydk Mar 3, 2025
520658c
Merge branch 'main' into customize
freddydk Mar 4, 2025
ec120e7
Merge branch 'main' into customize
freddydk Mar 14, 2025
0c834a0
Merge branch 'main' into customize
freddydk Mar 17, 2025
75a7fb5
template settings
freddydk Mar 23, 2025
941d95f
dstpath
freddydk Mar 23, 2025
a3ab9cd
indirect
freddydk Mar 23, 2025
e22005b
use indirect
freddydk Mar 23, 2025
b1e6a23
test correct type
freddydk Mar 23, 2025
ab8fb22
test
freddydk Mar 23, 2025
ffd2164
()
freddydk Mar 23, 2025
6f4cc98
name
freddydk Mar 23, 2025
950a27e
use
freddydk Mar 23, 2025
83cb259
)
freddydk Mar 23, 2025
a160fb4
Merge branch 'main' into customize
freddydk Mar 23, 2025
a4bb65c
document cicd authcontext
freddydk Mar 23, 2025
71d5ce4
merge or add
freddydk Mar 23, 2025
03aa396
perm
freddydk Mar 23, 2025
a1c2d3a
syntax
freddydk Mar 23, 2025
67dd184
insert
freddydk Mar 23, 2025
cfdaac9
parent
freddydk Mar 24, 2025
65f7798
support global permissions
freddydk Mar 24, 2025
87bb4e3
read secret
freddydk Mar 25, 2025
cacf9e3
Update Scenarios/Contribute.md
freddydk Mar 25, 2025
7fa9ccb
Update Scenarios/CustomizingALGoForGitHub.md
freddydk Mar 25, 2025
ad90d28
Update Scenarios/CustomizingALGoForGitHub.md
freddydk Mar 25, 2025
e5d60ca
Update Scenarios/CustomizingALGoForGitHub.md
freddydk Mar 25, 2025
2451a21
Update Actions/CheckForUpdates/CheckForUpdates.ps1
freddydk Mar 25, 2025
f079b07
remove spaces
freddydk Mar 25, 2025
7fa0ca6
Merge branch 'main' into customize
freddydk Mar 27, 2025
028d652
Merge branch 'main' into customize
freddydk Apr 11, 2025
acd41e8
Merge branch 'main' into customize
freddydk Apr 16, 2025
8d9c6e3
Update Scenarios/CustomizingALGoForGitHub.md
freddydk Apr 17, 2025
4e88c46
docs
freddydk Apr 17, 2025
c10e74a
Merge branch 'customize' of https://github.com/freddydk/AL-Go into cu…
freddydk Apr 17, 2025
add7a0b
Only use harden_runner on microsoft
freddydk Apr 17, 2025
aa1b5c6
Merge branch 'main' into customize
freddydk Apr 22, 2025
22abae7
Asess token in downloadTemplateRepo instead of early on
freddydk Apr 22, 2025
73665c3
rename tokens
freddydk Apr 22, 2025
53421d9
warn
freddydk Apr 22, 2025
87cafa4
use token
freddydk Apr 22, 2025
9d2349e
Update Actions/CheckForUpdates/CheckForUpdates.ps1
freddydk Apr 22, 2025
7e01871
Update Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1
freddydk Apr 22, 2025
b7725ca
rename internal file
freddydk Apr 22, 2025
f1afbff
add docs
freddydk Apr 22, 2025
7ca8ac2
fix ci test
freddydk Apr 22, 2025
30a3bd5
Merge branch 'main' into customize
freddydk Apr 23, 2025
cbf025a
Merge branch 'main' into customize
freddydk Apr 23, 2025
e53180b
remove cicdauthcontext
freddydk Apr 24, 2025
6349cd5
revert
freddydk Apr 24, 2025
1aaf794
Remove custom steps
freddydk Apr 24, 2025
3c7a9a7
add authentication for custom files
freddydk Apr 24, 2025
fde3d9d
use source
freddydk Apr 24, 2025
8fd6fdc
comment
freddydk Apr 24, 2025
dc5f89f
getheaders
freddydk Apr 24, 2025
5215c9f
read secrets
freddydk Apr 24, 2025
4e7e419
dump properties
freddydk Apr 24, 2025
8ee2962
ht
freddydk Apr 24, 2025
d5da27c
get repo name
freddydk Apr 24, 2025
ddb2dbf
dumps
freddydk Apr 24, 2025
e109d67
default zip
freddydk Apr 24, 2025
f1e019d
support api.gi...
freddydk Apr 24, 2025
365dc51
add filespec
freddydk Apr 24, 2025
3f43611
add force
freddydk Apr 24, 2025
4786ae7
docs
freddydk Apr 24, 2025
43605b2
remove
freddydk Apr 24, 2025
15d54e2
optional secrets
freddydk Apr 25, 2025
cc12c09
S
freddydk Apr 25, 2025
35ca22a
remove permissions merge (as we only support custom jobs)
freddydk Apr 28, 2025
b5ed00e
modify e2e
freddydk Apr 28, 2025
7c2b37c
Merge branch 'main' into customize
freddydk Apr 29, 2025
5a7a2a2
indent
freddydk Apr 29, 2025
0b14be0
Merge branch 'main' into customize
freddydk May 1, 2025
e2ac67f
move
freddydk May 1, 2025
905678d
Merge branch 'main' into customize
freddydk May 8, 2025
817f7ee
get secrets
freddydk May 8, 2025
d8523dd
dumop
freddydk May 8, 2025
0f133fe
Merge branch 'main' into customize
freddydk May 14, 2025
c97fd33
add customALGoSystemFiles
freddydk May 14, 2025
94c6573
read info from realSrcFile
freddydk May 15, 2025
e2ee4cd
do not fail on missing schema
freddydk May 15, 2025
f9885ec
Merge branch 'main' into customize
freddydk May 15, 2025
603a552
Merge branch 'main' into customize
freddydk May 21, 2025
829ef73
Fix merge err
freddydk May 22, 2025
be455b5
Update Scenarios/settings.md
freddydk May 29, 2025
1c45ca4
Update Actions/CheckForUpdates/CheckForUpdates.ps1
freddydk May 29, 2025
0e27b40
Update Actions/CheckForUpdates/CheckForUpdates.ps1
freddydk May 29, 2025
4ddc87b
review
freddydk May 29, 2025
8d56049
Merge branch 'customize' of https://github.com/freddydk/AL-Go into cu…
freddydk May 29, 2025
b91717f
review
freddydk May 29, 2025
e107d09
remove templateheaders - is handled in download function
freddydk May 29, 2025
fdb5be5
Merge branch 'main' into customize
freddydk May 29, 2025
4ed5800
Update Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1
freddydk Jun 1, 2025
33bdb53
Update Actions/CheckForUpdates/CheckForUpdates.ps1
freddydk Jun 1, 2025
5be373f
Update Actions/CheckForUpdates/CheckForUpdates.ps1
freddydk Jun 1, 2025
89dd776
Remove CustomALGoSystemFiles and review comments
freddydk Jun 1, 2025
2093b31
Update Scenarios/CustomizingALGoForGitHub.md
freddydk Jun 1, 2025
f588939
Update Scenarios/CustomizingALGoForGitHub.md
freddydk Jun 2, 2025
4c9742a
Update Scenarios/CustomizingALGoForGitHub.md
freddydk Jun 2, 2025
50928d9
Update Actions/Github-Helper.psm1
freddydk Jun 2, 2025
e99e853
Update Scenarios/CustomizingALGoForGitHub.md
freddydk Jun 2, 2025
42c8204
review
freddydk Jun 2, 2025
9801efc
rename to custom template
freddydk Jun 2, 2025
79211b6
review
freddydk Jun 2, 2025
f2e931a
Update Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1
freddydk Jun 5, 2025
c601c39
review
freddydk Jun 5, 2025
b8f2aa5
Merge branch 'main' into customize
freddydk Jun 5, 2025
9895d9f
move target
freddydk Jun 5, 2025
f3b6bf3
remove duplicates always
freddydk Jun 5, 2025
fe30ec4
fix issue with private/internal template repo
freddydk Jun 5, 2025
6323421
update parameters
freddydk Jun 5, 2025
7f4b380
add al-go-helper
freddydk Jun 5, 2025
6784d3b
Merge branch 'main' into customize
freddydk Jun 5, 2025
9cedb34
fix end 2 end
freddydk Jun 6, 2025
36b561e
Merge branch 'customize' of https://github.com/freddydk/AL-Go into cu…
freddydk Jun 6, 2025
dc2928a
Update CustomizingALGoForGitHub.md
freddydk Jun 13, 2025
28a378c
Update Index.md
freddydk Jun 13, 2025
177bb2e
Merge branch 'main' into customize
freddydk Jun 13, 2025
f0a6adc
review
freddydk Jun 13, 2025
85d7973
review
freddydk Jun 13, 2025
fa7e33e
Update RELEASENOTES.md
freddydk Jun 13, 2025
6372d4d
review
freddydk Jun 13, 2025
ea63c85
Merge branch 'customize' of https://github.com/freddydk/AL-Go into cu…
freddydk Jun 13, 2025
9867aec
rename first
freddydk Jun 13, 2025
cbc9cc5
rename
freddydk Jun 13, 2025
1106eb1
add telemetry
freddydk Jun 13, 2025
688b3b7
Merge branch 'main' into customize
freddydk Jun 17, 2025
7efa243
Merge branch 'main' into customize
freddydk Jun 17, 2025
b74f3a3
Update Actions/CheckForUpdates/CheckForUpdates.ps1
freddydk Jun 19, 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
19 changes: 18 additions & 1 deletion Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-S
$ALGoFolderName = '.AL-Go'
$ALGoSettingsFile = Join-Path '.AL-Go' 'settings.json'
$RepoSettingsFile = Join-Path '.github' 'AL-Go-Settings.json'
$IndirectTemplateRepoSettingsFile = Join-Path '.github' 'templateRepoSettings.json'
$IndirectTemplateProjectSettingsFile = Join-Path '.github' 'templateProjectSettings.json'
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'defaultCICDPushBranches', Justification = 'False positive.')]
$defaultCICDPushBranches = @( 'main', 'release/*', 'feature/*' )
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'defaultCICDPullRequestBranches', Justification = 'False positive.')]
$defaultCICDPullRequestBranches = @( 'main' )
$runningLocal = $local.IsPresent
$defaultBcContainerHelperVersion = "preview" # Must be double quotes. Will be replaced by BcContainerHelperVersion if necessary in the deploy step - ex. "https://github.com/organization/navcontainerhelper/archive/refs/heads/branch.zip"
$notSecretProperties = @("Scopes","TenantId","BlobName","ContainerName","StorageAccountName","ServerUrl","ppUserName","GitHubAppClientId")
$notSecretProperties = @("Scopes","TenantId","BlobName","ContainerName","StorageAccountName","ServerUrl","ppUserName","GitHubAppClientId","EnvironmentName")

$runAlPipelineOverrides = @(
"DockerPull"
Expand All @@ -38,6 +40,8 @@ $runAlPipelineOverrides = @(
"InstallMissingDependencies"
"PreCompileApp"
"PostCompileApp"
"PipelineInitialize"
"PipelineFinalize"
)

# Well known AppIds
Expand Down Expand Up @@ -500,6 +504,10 @@ function MergeCustomObjectIntoOrderedDictionary {
if ($srcPropType -eq "PSCustomObject" -and $dstPropType -eq "OrderedDictionary") {
MergeCustomObjectIntoOrderedDictionary -dst $dst."$prop" -src $srcProp
}
elseif ($dstProp -is [String] -and $srcProp -is [Object[]]) {
# For properties like "runs-on", which is a string, you can specify an array in settings, which gets joined with a comma
$dst."$prop" = $srcProp -join ', '
}
elseif ($dstPropType -ne $srcPropType -and !($srcPropType -eq "Int64" -and $dstPropType -eq "Int32")) {
# Under Linux, the Int fields read from the .json file will be Int64, while the settings defaults will be Int32
# This is not seen as an error and will not throw an error
Expand Down Expand Up @@ -535,8 +543,10 @@ function MergeCustomObjectIntoOrderedDictionary {
# Read settings from the settings files
# Settings are read from the following files:
# - ALGoOrgSettings (github Variable) = Organization settings variable
# - .github/templateRepoSettings.json = Repository settings from indirect template
# - .github/AL-Go-Settings.json = Repository Settings file
# - ALGoRepoSettings (github Variable) = Repository settings variable
# - .github/templateProjectSettings.json = Project settings from indirect template
# - <project>/.AL-Go/settings.json = Project settings file
# - .github/<workflowName>.settings.json = Workflow settings file
# - <project>/.AL-Go/<workflowName>.settings.json = Project workflow settings file
Expand Down Expand Up @@ -591,6 +601,7 @@ function ReadSettings {
$settings = [ordered]@{
"type" = "PTE"
"unusedALGoSystemFiles" = @()
"customALGoSystemFiles" = @()
"projects" = @()
"powerPlatformSolutionFolder" = ""
"country" = "us"
Expand Down Expand Up @@ -733,6 +744,9 @@ function ReadSettings {
$settingsObjects += @($orgSettingsVariableObject)
}
# Read settings from repository settings file
$indirectTemplateRepoSettingsObject = GetSettingsObject -Path (Join-Path $baseFolder $IndirectTemplateRepoSettingsFile)
$settingsObjects += @($indirectTemplateRepoSettingsObject)
# Read settings from repository settings file
$repoSettingsObject = GetSettingsObject -Path (Join-Path $baseFolder $RepoSettingsFile)
$settingsObjects += @($repoSettingsObject)
# Read settings from repository settings variable (parameter)
Expand All @@ -741,6 +755,9 @@ function ReadSettings {
$settingsObjects += @($repoSettingsVariableObject)
}
if ($project) {
# Read settings from repository settings file
$indirectTemplateProjectSettingsObject = GetSettingsObject -Path (Join-Path $baseFolder $IndirectTemplateProjectSettingsFile)
$settingsObjects += @($indirectTemplateProjectSettingsObject)
# Read settings from project settings file
$projectFolder = Join-Path $baseFolder $project -Resolve
$projectSettingsObject = GetSettingsObject -Path (Join-Path $projectFolder $ALGoSettingsFile)
Expand Down
13 changes: 9 additions & 4 deletions Actions/AL-Go-TestRepoHelper.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
function Test-Property {
. (Join-Path $PSScriptRoot "AL-Go-Helper.ps1")

function Test-Property {
Param(
[HashTable] $json,
[string] $settingsDescription,
Expand Down Expand Up @@ -174,13 +176,16 @@ function TestALGoRepository {
# Test .json files are formatted correctly
# Get-ChildItem needs -force to include folders starting with . (e.x. .github / .AL-Go) on Linux
Get-ChildItem -Path $baseFolder -Filter '*.json' -Recurse -Force | ForEach-Object {
if ($_.Directory.Name -eq '.AL-Go' -and $_.BaseName -eq 'settings') {
if ($_.Directory.Name -eq ([System.IO.Path]::GetDirectoryName($ALGoSettingsFile)) -and $_.Name -eq ([System.IO.Path]::GetFileName($ALGoSettingsFile))) {
Test-JsonFile -jsonFile $_.FullName -baseFolder $baseFolder -type 'Project'
}
elseif ($_.Directory.Name -eq '.github' -and $_.BaseName -like '*ettings') {
if ($_.BaseName -eq 'AL-Go-Settings') {
elseif ($_.Directory.Name -eq ([System.IO.Path]::GetDirectoryName($RepoSettingsFile)) -and $_.BaseName -like '*ettings') {
if ($_.Name -eq ([System.IO.Path]::GetFileName($RepoSettingsFile)) -or $_.Name -eq ([System.IO.Path]::GetFileName($IndirectTemplateRepoSettingsFile))) {
$type = 'Repo'
}
elseif ($_.Name -eq ([System.IO.Path]::GetFileName($IndirectTemplateProjectSettingsFile))) {
$type = 'Project'
}
else {
$type = 'Workflow'
}
Expand Down
144 changes: 132 additions & 12 deletions Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
function GetCustomizationAnchors {
return @{
"_BuildALGoProject.yaml" = @{
"BuildALGoProject" = @(
@{ "Step" = 'Read settings'; "Before" = $false }
@{ "Step" = 'Read secrets'; "Before" = $false }
@{ "Step" = 'Build'; "Before" = $true }
@{ "Step" = 'Build'; "Before" = $false }
@{ "Step" = 'Cleanup'; "Before" = $true }
)
}
}
}

<#
.SYNOPSIS
Downloads a template repository and returns the path to the downloaded folder
Expand Down Expand Up @@ -446,7 +460,7 @@ function IsDirectALGo {

function GetSrcFolder {
Param(
[hashtable] $repoSettings,
[string] $repoType,
[string] $templateUrl,
[string] $templateFolder,
[string] $srcPath
Expand All @@ -458,7 +472,7 @@ function GetSrcFolder {
return ''
}
if (IsDirectALGo -templateUrl $templateUrl) {
switch ($repoSettings.type) {
switch ($repoType) {
"PTE" {
$typePath = "Per Tenant Extension"
}
Expand Down Expand Up @@ -488,33 +502,139 @@ function GetSrcFolder {
function UpdateSettingsFile {
Param(
[string] $settingsFile,
[hashtable] $updateSettings,
[hashtable] $additionalSettings = @{}
[hashtable] $updateSettings
)

$modified = $false
# Update Repo Settings file with the template URL
if (Test-Path $settingsFile) {
$settings = Get-Content $settingsFile -Encoding UTF8 | ConvertFrom-Json
}
else {
$settings = [PSCustomObject]@{}
$modified = $true
}
foreach($key in $updateSettings.Keys) {
if ($settings.PSObject.Properties.Name -eq $key) {
$settings."$key" = $updateSettings."$key"
if ($settings."$key" -ne $updateSettings."$key") {
$settings."$key" = $updateSettings."$key"
$modified = $true
}
}
else {
# Add the property if it doesn't exist
$settings | Add-Member -MemberType NoteProperty -Name "$key" -Value $updateSettings."$key"
$modified = $true
}
}
# Grab settings from additionalSettings if they are not already in settings
foreach($key in $additionalSettings.Keys) {
if (!($settings.PSObject.Properties.Name -eq $key)) {
# Add the property if it doesn't exist
$settings | Add-Member -MemberType NoteProperty -Name "$key" -Value $additionalSettings."$key"
if ($modified) {
# Save the file with LF line endings and UTF8 encoding
$settings | Set-JsonContentLF -path $settingsFile
}
return $modified
}

function GetCustomALGoSystemFiles {
Param(
[string] $baseFolder,
[hashtable] $settings,
[string[]] $projects
)

function YieldItem{
Param(
[string] $baseFolder,
[string] $source,
[string] $destination,
[string[]] $projects
)

if ($destination -like ".AL-Go$([IO.Path]::DirectorySeparatorChar)*") {
$destinations = $projects | ForEach-Object { Join-Path $_ $destination }
}
else {
$destinations = @($destination)
}
$destinations | ForEach-Object {
Write-Host "- $_"
$content = Get-ContentLF -Path $source
$existingFile = Join-Path $baseFolder $_
$existingContent = ''
if (Test-Path -Path $existingFile) {
$existingContent = Get-ContentLF -Path $existingFile
}
if ($content -ne $existingContent) {
Write-Output @{ "DstFile" = $_; "content" = $content }
}
}
}

if ($settings.customALGoSystemFiles -isnot [Array]) {
throw "customALGoSystemFiles setting is wrongly formatted, must be an array of objects. See https://aka.ms/algosettings#customalgosystemfiles."
}
foreach($customspec in $settings.customALGoSystemFiles) {
if ($customspec -isnot [Hashtable]) {
throw "customALGoSystemFiles setting is wrongly formatted, must be an array of objects. See https://aka.ms/algosettings#customalgosystemfiles."
}
if (!($customSpec.ContainsKey('Source') -and $customSpec.ContainsKey('Destination'))) {
throw "customALGoSystemFiles setting is wrongly formatted, Source and Destination must be specified. See https://aka.ms/algosettings#customalgosystemfiles."
}
$source = $customspec.Source
$destination = $customSpec.Destination.Replace('/',[IO.Path]::DirectorySeparatorChar).Replace('\',[IO.Path]::DirectorySeparatorChar)
if ($destination -isnot [string] -or $destination -eq '') {
throw "customALGoSystemFiles setting is wrongly formatted, Destination must be a string, which isn't blank. See https://aka.ms/algosettings#customalgosystemfiles."
}
if ($source -isnot [string] -or $source -notlike 'https://*' -or (-not [System.Uri]::IsWellFormedUriString($source,1))) {
throw "customALGoSystemFiles setting is wrongly formatted, Source must secure download URL. See https://aka.ms/algosettings#customalgosystemfiles."
}

$tempFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
New-Item -Path $tempFolder -ItemType Directory | Out-Null
$ext = [System.IO.Path]::GetExtension($source)
$zipName = "$tempFolder$ext"
try {
if ($ext -eq '.zip') {
Write-Host "$($destination):"
if ($customSpec.ContainsKey('FileSpec')) { $fileSpec = $customSpec.FileSpec } else { $fileSpec = '*' }
if ($customSpec.ContainsKey('Recurse')) { $recurse = $customSpec.Recurse } else { $recurse = $true }
if ($fileSpec -isnot [string] -or $recurse -isnot [boolean]) {
throw "customALGoSystemFiles setting is wrongly formatted, fileSpec must be string and Recurse must be boolean. See https://aka.ms/algosettings#customalgosystemfiles."
}
if (!($destination.EndsWith('/') -or $destination.EndsWith('\'))) {
throw "customALGoSystemFiles setting is wrongly formatted, destination must be a folder (terminated with / or \). See https://aka.ms/algosettings#customalgosystemfiles."
}
Invoke-RestMethod -UseBasicParsing -Method Get -Uri $source -OutFile $zipName
Expand-Archive -Path $zipName -DestinationPath $tempFolder -Force
$subFolder = Join-Path $tempFolder ([System.IO.Path]::GetDirectoryName($fileSpec)) -Resolve
Push-Location -Path $subFolder
try {
Get-ChildItem -Path $subFolder -Filter ([System.IO.Path]::GetFileName($fileSpec)) -Recurse:$recurse -File | ForEach-Object {
$destRelativeFileName = Resolve-Path $_.FullName -Relative
$destFileName = Join-Path $destination $destRelativeFileName
$destFileName = $destFileName.TrimStart('\/')
YieldItem -baseFolder $baseFolder -source $_.FullName -destination $destFileName -projects $projects
}
}
finally {
Pop-Location
}
}
else {
if ($customSpec.ContainsKey('FileSpec') -or $customSpec.ContainsKey('Recurse')) {
throw "customALGoSystemFiles setting is wrongly formatted, FileSpec and Recurse are only allowed with .zip files. See https://aka.ms/algosettings#customalgosystemfiles."
}
if ($destination.endsWith([IO.Path]::DirectorySeparatorChar)) {
$destination = Join-Path $destination ([System.IO.Path]::GetFileName($source))
}
Write-Host "$($destination):"
$tempFilename = Join-Path $tempFolder ([System.IO.Path]::GetFileName($source))
Invoke-RestMethod -UseBasicParsing -Method Get -Uri $source -OutFile $tempFilename
YieldItem -baseFolder $baseFolder -source $tempFilename -destination $destination -projects $projects
}
}
finally {
if (Test-Path -Path $zipName) { Remove-Item $zipName -Force }
Remove-Item -Path $tempFolder -Recurse -Force
}
}
# Save the file with LF line endings and UTF8 encoding
$settings | Set-JsonContentLF -path $settingsFile
}
Loading
Loading