Skip to content

Commit

Permalink
Merge branch 'deployurl' of https://github.com/freddydk/AL-Go into de…
Browse files Browse the repository at this point in the history
…ployurl
  • Loading branch information
freddydk committed Oct 2, 2023
2 parents 3e3aef1 + 77fa0fa commit c1ae88d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/Deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:
required: false
default: false
defaultBcContainerHelperVersion:
description: 'Which version of BcContainerHelper to use? (latest, preview, private, a specific version number or a direct download URL like https://github.com/freddydk/navcontainerhelper/archive/master.zip - leave empty to use latest)'
description: 'Which version of BcContainerHelper to use? (latest, preview, private, a specific version number or a direct download URL like https://github.com/freddydk/navcontainerhelper/archive/master.zip). Leave empty to use latest (or preview for preview branches)'
required: false
default: ''

Expand Down Expand Up @@ -68,6 +68,13 @@ jobs:
throw "In order to run the Deploy workflow, you need a Secret called OrgPAT containing a valid Personal Access Token"
}
$githubOwner = "$ENV:GITHUB_REPOSITORY_OWNER"
if ("$env:defaultBcContainerHelperVersion" -eq "") {
if ($env:branch -eq 'preview') {
$env:defaultBcContainerHelperVersion = 'preview'
} else {
$env:defaultBcContainerHelperVersion = 'latest'
}
}
$config = @{
"githubOwner" = $githubOwner
"actionsRepo" = "AL-Go-Actions"
Expand Down
14 changes: 12 additions & 2 deletions Internal/Deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,18 @@ try {
$lines = $lines | ForEach-Object { $_ -replace $regex, $replace }
}
if ($_.Name -eq "AL-Go-Helper.ps1" -and ($config.ContainsKey("defaultBcContainerHelperVersion") -and $config.defaultBcContainerHelperVersion)) {
# replace defaultBcContainerHelperVersion (even if a version is set)
$lines = $lines | ForEach-Object { $_ -replace '^(\s*)\$defaultBcContainerHelperVersion(\s*)=(\s*)"(.*)" # (.*)$', "`${1}`$defaultBcContainerHelperVersion`${2}=`${3}""$($config.defaultBcContainerHelperVersion)"" # `${5}" }
# replace defaultBcContainerHelperVersion
$found = $false
for($idx=0; $idx -lt $lines.count; $idx++) {
if ($lines[$idx] -match '^(\s*)\$defaultBcContainerHelperVersion(\s*)=(\s*)"(.*)" # (.*)$') {
$lines[$idx] = "$($Matches[1])`$defaultBcContainerHelperVersion$($Matches[2])=$($Matches[3])""$($config.defaultBcContainerHelperVersion)"" # $($Matches[5])"
$found = $true
break
}
}
if (-not $found) {
throw 'Could not find defaultBcContainerHelperVersion line in AL-Go-Helpers.ps1 matching "^(\s*)\$defaultBcContainerHelperVersion(\s*)=(\s*)"(.*)" # (.*)$"'
}
}
[System.IO.File]::WriteAllText($dstFile, "$($lines -join "`n")`n")
}
Expand Down

0 comments on commit c1ae88d

Please sign in to comment.