mirror of
https://github.com/actions/go-versions.git
synced 2025-07-18 13:18:24 +02:00
Update logic
This commit is contained in:
parent
a3ba0f5826
commit
6e1322a96e
1 changed files with 4 additions and 19 deletions
|
@ -18,32 +18,17 @@ Describe "Go" {
|
||||||
$logsFolderPath = $possiblePaths | Where-Object { Test-Path $_ } | Select-Object -First 1
|
$logsFolderPath = $possiblePaths | Where-Object { Test-Path $_ } | Select-Object -First 1
|
||||||
$resolvedPath = Resolve-Path -Path $logsFolderPath -ErrorAction SilentlyContinue
|
$resolvedPath = Resolve-Path -Path $logsFolderPath -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
if (-not [string]::IsNullOrEmpty($resolvedPath) -and (Test-Path $resolvedPath)) {
|
if ($resolvedPath -and -not [string]::IsNullOrEmpty($resolvedPath.Path) -and (Test-Path $resolvedPath.Path)) {
|
||||||
if ($logsFolderPath -eq "actions-runner/cached/_diag/pages") {
|
|
||||||
try {
|
|
||||||
$useGoLogFile = Get-ChildItem -Path $logsFolderPath -File| Where-Object {
|
|
||||||
if (-not $_.PSIsContainer) { # Ensure it's not a directory
|
|
||||||
$logContent = Get-Content $_.Fullname -Raw
|
|
||||||
return $logContent -match "setup-go@v"
|
|
||||||
}
|
|
||||||
} | Select-Object -First 1
|
|
||||||
} catch {
|
|
||||||
Write-Error "Failed to resolve path: $logsFolderPath"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$useGoLogFile = Get-ChildItem -Path $resolvedPath | Where-Object {
|
$useGoLogFile = Get-ChildItem -Path $resolvedPath | Where-Object {
|
||||||
if (-not $_.PSIsContainer) { # Ensure it's not a directory
|
|
||||||
$logContent = Get-Content $_.Fullname -Raw
|
$logContent = Get-Content $_.Fullname -Raw
|
||||||
return $logContent -match "setup-go@v"
|
return $logContent -match "setup-go@v"
|
||||||
}
|
|
||||||
} | Select-Object -First 1
|
} | Select-Object -First 1
|
||||||
}
|
|
||||||
|
|
||||||
# Return the file name if a match is found
|
# Return the file name if a match is found
|
||||||
if ($useGoLogFile) {
|
if ($useGoLogFile) {
|
||||||
return $useGoLogFile.FullName
|
return $useGoLogFile.FullName
|
||||||
} else {
|
} else {
|
||||||
Write-Error "No matching log file found in the specified path."
|
Write-Error "No matching log file found in the specified path: $($resolvedPath.Path)"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Error "The provided logs folder path is null, empty, or does not exist: $logsFolderPath"
|
Write-Error "The provided logs folder path is null, empty, or does not exist: $logsFolderPath"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue