Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
freddydk committed Aug 7, 2023
1 parent f290412 commit 21cc2cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Collect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
}
$settingsFile = Join-Path $settings.baseFolder "deploy.json"
$settings | ConvertTo-Json | Set-Content $settingsFile -Encoding UTF8
. ".\Internal\Collect.ps1" -configName $settingsFile -githubOwner $githubOwner -token $token -github -directCOMMIT:('${{ github.event.inputs.directCOMMIT }}' -eq 'Y')
. ".\Internal\Collect.ps1" -configName $settingsFile -githubOwner $githubOwner -token $token -directCOMMIT:('${{ github.event.inputs.directCOMMIT }}' -eq 'Y')
}
}
catch {
Expand Down
30 changes: 7 additions & 23 deletions Internal/Collect.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[string] $githubOwner,
[string] $token,
[string] $algoBranch,
[switch] $github,
[switch] $directCommit
)

Expand All @@ -15,21 +14,15 @@ Write-Host "::WARNING::The collect mechanism is deprecated. Use the new direct A

$oldPath = Get-Location
try {
if ($github) {
if (!$githubOwner -or !$token) { throw "When running deploy in a workflow, you need to set githubOwner and token" }

invoke-git config --global user.email "$githubOwner@users.noreply.github.com"
invoke-git config --global user.name "$githubOwner"
invoke-git config --global hub.protocol https
invoke-git config --global core.autocrlf false
$ENV:GITHUB_TOKEN = ''
}
invoke-git config --global user.email "$githubOwner@users.noreply.github.com"
invoke-git config --global user.name "$githubOwner"
invoke-git config --global hub.protocol https
invoke-git config --global core.autocrlf false
$ENV:GITHUB_TOKEN = ''

Write-Host "Authenticating with GitHub using token"
$token | invoke-gh auth login --with-token
if ($github) {
$ENV:GITHUB_TOKEN = $token
}
$ENV:GITHUB_TOKEN = $token

$originalOwnerAndRepo = @{
"actionsRepo" = "microsoft/AL-Go-Actions"
Expand Down Expand Up @@ -107,10 +100,6 @@ try {
Write-Host "To the $algoBranch branch from $srcOwnerAndRepo (folder $baseRepoPath)"
Write-Host

if (-not $github) {
Read-Host "If this is not what you want to do, then press Ctrl+C now, else press Enter."
}

$config.actionsRepo, $config.perTenantExtensionRepo, $config.appSourceAppRepo | ForEach-Object {
if (Test-Path $_) {
Set-Location $_
Expand Down Expand Up @@ -179,12 +168,7 @@ try {
}
Set-Location $baseRepoPath

if ($github) {
$serverUrl = "https://$($user.login):$token@github.com/$($srcOwnerAndRepo).git"
}
else {
$serverUrl = "https://github.com/$($srcOwnerAndRepo).git"
}
$serverUrl = "https://$($user.login):$token@github.com/$($srcOwnerAndRepo).git"

$commitMessage = "Collect changes from $($config.githubOwner)/*@$($config.branch)"
invoke-git add *
Expand Down
2 changes: 1 addition & 1 deletion Internal/Deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ try {

if ($config.branch -eq 'preview') {
# When deploying to preview, we are NOT going to deploy to a branch in the AL-Go-Actions repository
# Instead, we are going to have AL-Go-PTE and AL-Go-Actions point directly to the SHA in AL-Go
# Instead, we are going to have AL-Go-PTE and AL-Go-AppSource point directly to the SHA in AL-Go
$dstOwnerAndRepo += @{
"actionsRepo" = "$srcOwnerAndRepo/Actions@$srcSHA"
}
Expand Down

0 comments on commit 21cc2cf

Please sign in to comment.