From 24826f55707ae93071fe8f9e42ca48aa739bf8e0 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 10:04:37 +0100 Subject: [PATCH 01/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Refactor=20main?= =?UTF-8?q?=20and=20outputs=20scripts=20for=20improved=20readability=20and?= =?UTF-8?q?=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 161 +++++++++++++++++++++++--------------------- scripts/outputs.ps1 | 48 +++++++------ 2 files changed, 114 insertions(+), 95 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index e763153..ce85224 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -1,93 +1,104 @@ [CmdletBinding()] param() -$env:PSMODULE_GITHUB_SCRIPT = $true -Write-Host '┏━━━━━┫ GitHub-Script ┣━━━━━┓' -Write-Host '::group:: - Setup GitHub PowerShell' +begin { + $stackPath = Get-PSCallStackPath + Write-Debug "[$stackPath] - Start" +} -$Name = 'GitHub' -$Version = [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Version) ? $null : $env:GITHUB_ACTION_INPUT_Version -$Prerelease = $env:GITHUB_ACTION_INPUT_Prerelease -eq 'true' +process { + $env:PSMODULE_GITHUB_SCRIPT = $true + Write-Host '┏━━━━━┫ GitHub-Script ┣━━━━━┓' + Write-Host '::group:: - Setup GitHub PowerShell' -$alreadyInstalled = Get-InstalledPSResource -Name $Name -ErrorAction SilentlyContinue -if ($Version) { - Write-Verbose "Filtering by version: $Version" - $alreadyInstalled = $alreadyInstalled | Where-Object Version -EQ $Version -} -if ($Prerelease) { - Write-Verbose 'Filtering by prerelease' - $alreadyInstalled = $alreadyInstalled | Where-Object Prerelease -EQ $Prerelease -} -Write-Verbose 'Already installed:' -$alreadyInstalled | Format-Table -if (-not $alreadyInstalled) { - $params = @{ - Name = $Name - Repository = 'PSGallery' - TrustRepository = $true - Prerelease = $Prerelease - } + $Name = 'GitHub' + $Version = [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Version) ? $null : $env:GITHUB_ACTION_INPUT_Version + $Prerelease = $env:GITHUB_ACTION_INPUT_Prerelease -eq 'true' + + $alreadyInstalled = Get-InstalledPSResource -Name $Name -ErrorAction SilentlyContinue if ($Version) { - $params['Version'] = $Version + Write-Verbose "Filtering by version: $Version" + $alreadyInstalled = $alreadyInstalled | Where-Object Version -EQ $Version } - $Count = 5 - $Delay = 10 - for ($i = 1; $i -le $Count; $i++) { - try { - Install-PSResource @params - break - } catch { - if ($i -eq $Count) { - throw $_ + if ($Prerelease) { + Write-Verbose 'Filtering by prerelease' + $alreadyInstalled = $alreadyInstalled | Where-Object Prerelease -EQ $Prerelease + } + Write-Verbose 'Already installed:' + $alreadyInstalled | Format-Table + if (-not $alreadyInstalled) { + $params = @{ + Name = $Name + Repository = 'PSGallery' + TrustRepository = $true + Prerelease = $Prerelease + } + if ($Version) { + $params['Version'] = $Version + } + $Count = 5 + $Delay = 10 + for ($i = 1; $i -le $Count; $i++) { + try { + Install-PSResource @params + break + } catch { + if ($i -eq $Count) { + throw $_ + } + Start-Sleep -Seconds $Delay } - Start-Sleep -Seconds $Delay } } -} -$alreadyImported = Get-Module -Name $Name -Write-Verbose 'Already imported:' -$alreadyImported | Format-Table -if (-not $alreadyImported) { - Write-Verbose "Importing module: $Name" - Import-Module -Name $Name -} + $alreadyImported = Get-Module -Name $Name + Write-Verbose 'Already imported:' + $alreadyImported | Format-Table + if (-not $alreadyImported) { + Write-Verbose "Importing module: $Name" + Import-Module -Name $Name + } -$providedToken = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Token) -$providedClientID = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_ClientID) -$providedPrivateKey = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_PrivateKey) -[pscustomobject]@{ - Name = $Name - Version = [string]::IsNullOrEmpty($Version) ? 'latest' : $Version - Prerelease = $Prerelease - 'Already installed' = $null -ne $alreadyInstalled - 'Already imported' = $null -ne $alreadyImported - 'Provided Token' = $providedToken - 'Provided ClientID' = $providedClientID - 'Provided PrivateKey' = $providedPrivateKey -} | Format-List -Write-Host '::endgroup::' + $providedToken = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Token) + $providedClientID = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_ClientID) + $providedPrivateKey = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_PrivateKey) + [pscustomobject]@{ + Name = $Name + Version = [string]::IsNullOrEmpty($Version) ? 'latest' : $Version + Prerelease = $Prerelease + 'Already installed' = $null -ne $alreadyInstalled + 'Already imported' = $null -ne $alreadyImported + 'Provided Token' = $providedToken + 'Provided ClientID' = $providedClientID + 'Provided PrivateKey' = $providedPrivateKey + } | Format-List + Write-Host '::endgroup::' -LogGroup ' - Installed modules' { - Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Sort-Object -Property Name | Format-Table -AutoSize -} + LogGroup ' - Installed modules' { + Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Sort-Object -Property Name | Format-Table -AutoSize + } -LogGroup ' - GitHub connection' { - if ($providedClientID -and $providedPrivateKey) { - Write-Verbose 'Connected using provided GitHub App' - Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent - } elseif ($providedToken) { - Write-Verbose 'Connected using provided token' - Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent + LogGroup ' - GitHub connection' { + if ($providedClientID -and $providedPrivateKey) { + Write-Verbose 'Connected using provided GitHub App' + Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent + } elseif ($providedToken) { + Write-Verbose 'Connected using provided token' + Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent + } + Get-GitHubContext | Format-List } - Get-GitHubContext | Format-List -} -LogGroup ' - Configuration' { - Get-GitHubConfig | Format-List -} + LogGroup ' - Configuration' { + Get-GitHubConfig | Format-List + } -Write-Host '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' + Write-Host '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' -$DebugPreference = $env:GITHUB_ACTION_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue' -$VerbosePreference = $env:GITHUB_ACTION_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue' + $DebugPreference = $env:GITHUB_ACTION_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue' + $VerbosePreference = $env:GITHUB_ACTION_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue' +} + +end { + Write-Debug "[$stackPath] - End" +} diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 index f067d6a..f19b0d6 100644 --- a/scripts/outputs.ps1 +++ b/scripts/outputs.ps1 @@ -1,31 +1,39 @@ [CmdletBinding()] param() -$DebugPreference = 'SilentlyContinue' -$VerbosePreference = 'SilentlyContinue' - -if ($env:GITHUB_ACTION_INPUT_ShowOutput -ne 'true') { - return -} - -$result = (Get-GitHubOutput).result -if (-not $result) { - return +begin { + $stackPath = Get-PSCallStackPath + Write-Debug "[$stackPath] - Start" } -Write-Host '┏━━━━━┫ GitHub-Script ┣━━━━━┓' +process { + $DebugPreference = 'SilentlyContinue' + $VerbosePreference = 'SilentlyContinue' -LogGroup ' - Outputs' { - if ([string]::IsNullOrEmpty($env:GITHUB_ACTION)) { - Write-GitHubWarning 'Outputs cannot be accessed as the step has no ID.' + if ($env:GITHUB_ACTION_INPUT_ShowOutput -ne 'true') { + return } - if (-not (Test-Path -Path $env:GITHUB_OUTPUT)) { - Write-Warning "File not found: $env:GITHUB_OUTPUT" + $result = (Get-GitHubOutput).result + if (-not $result) { + return } - - $result | Format-List - Write-Host "Access outputs using `${{ fromJson(steps.$env:GITHUB_ACTION.outputs.result). }}" + Write-Host '┏━━━━━┫ GitHub-Script ┣━━━━━┓' + LogGroup ' - Outputs' { + if ([string]::IsNullOrEmpty($env:GITHUB_ACTION)) { + Write-GitHubWarning 'Outputs cannot be accessed as the step has no ID.' + } + + if (-not (Test-Path -Path $env:GITHUB_OUTPUT)) { + Write-Warning "File not found: $env:GITHUB_OUTPUT" + } + + $result | Format-List + Write-Host "Access outputs using `${{ fromJson(steps.$env:GITHUB_ACTION.outputs.result). }}" + } + Write-Host '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' } -Write-Host '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' +end { + Write-Debug "[$stackPath] - End" +} From d069849bc591b0c479b976c177e39e6deba866cf Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 10:06:54 +0100 Subject: [PATCH 02/23] =?UTF-8?q?=F0=9F=AA=B2=20[Fix]:=20Improve=20error?= =?UTF-8?q?=20handling=20in=20action.yml=20for=20script=20execution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 5935e46..c687895 100644 --- a/action.yml +++ b/action.yml @@ -66,6 +66,16 @@ runs: GITHUB_ACTION_INPUT_Prerelease: ${{ inputs.Prerelease }} run: | # GitHub-Script - . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1') + try { + . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1') + } catch { + Write-Error $_ + exit 1 + } ${{ inputs.Script }} - . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1') + try { + . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1') + } catch { + Write-Error $_ + exit 1 + } From da708fe8fc41ad42237cb94a279762ef5dac91b4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 10:08:34 +0100 Subject: [PATCH 03/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20debug?= =?UTF-8?q?=20messages=20in=20main=20and=20outputs=20scripts=20for=20consi?= =?UTF-8?q?stency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 5 ++--- scripts/outputs.ps1 | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index ce85224..8d70554 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -2,8 +2,7 @@ param() begin { - $stackPath = Get-PSCallStackPath - Write-Debug "[$stackPath] - Start" + Write-Debug "[main] - Start" } process { @@ -100,5 +99,5 @@ process { } end { - Write-Debug "[$stackPath] - End" + Write-Debug "[main] - End" } diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 index f19b0d6..bdbdb2f 100644 --- a/scripts/outputs.ps1 +++ b/scripts/outputs.ps1 @@ -2,8 +2,7 @@ param() begin { - $stackPath = Get-PSCallStackPath - Write-Debug "[$stackPath] - Start" + Write-Debug "[outputs] - Start" } process { @@ -35,5 +34,5 @@ process { } end { - Write-Debug "[$stackPath] - End" + Write-Debug "[outputs] - End" } From fe6f2a997a61221f21f0fb82b442158b71883eaa Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 10:43:48 +0100 Subject: [PATCH 04/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Enhance=20debug?= =?UTF-8?q?=20output=20and=20error=20handling=20in=20outputs.ps1=20for=20b?= =?UTF-8?q?etter=20traceability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/outputs.ps1 | 48 +++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 index bdbdb2f..a10c5e3 100644 --- a/scripts/outputs.ps1 +++ b/scripts/outputs.ps1 @@ -2,37 +2,43 @@ param() begin { - Write-Debug "[outputs] - Start" + Write-Debug '[outputs] - Start' } process { - $DebugPreference = 'SilentlyContinue' - $VerbosePreference = 'SilentlyContinue' + try { + $DebugPreference = 'SilentlyContinue' + $VerbosePreference = 'SilentlyContinue' - if ($env:GITHUB_ACTION_INPUT_ShowOutput -ne 'true') { - return - } - - $result = (Get-GitHubOutput).result - if (-not $result) { - return - } - Write-Host '┏━━━━━┫ GitHub-Script ┣━━━━━┓' - LogGroup ' - Outputs' { - if ([string]::IsNullOrEmpty($env:GITHUB_ACTION)) { - Write-GitHubWarning 'Outputs cannot be accessed as the step has no ID.' + Write-Debug "[outputs] - ShowOutput: $env:GITHUB_ACTION_INPUT_ShowOutput" + if ($env:GITHUB_ACTION_INPUT_ShowOutput -ne 'true') { + return } - if (-not (Test-Path -Path $env:GITHUB_OUTPUT)) { - Write-Warning "File not found: $env:GITHUB_OUTPUT" + $result = (Get-GitHubOutput).result + Write-Debug "[outputs] - Result: $(-not $result)" + if (-not $result) { + return } + Write-Host '┏━━━━━┫ GitHub-Script ┣━━━━━┓' + LogGroup ' - Outputs' { + if ([string]::IsNullOrEmpty($env:GITHUB_ACTION)) { + Write-GitHubWarning 'Outputs cannot be accessed as the step has no ID.' + } - $result | Format-List - Write-Host "Access outputs using `${{ fromJson(steps.$env:GITHUB_ACTION.outputs.result). }}" + if (-not (Test-Path -Path $env:GITHUB_OUTPUT)) { + Write-Warning "File not found: $env:GITHUB_OUTPUT" + } + + $result | Format-List + Write-Host "Access outputs using `${{ fromJson(steps.$env:GITHUB_ACTION.outputs.result). }}" + } + Write-Host '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' + } catch { + throw $_ } - Write-Host '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' } end { - Write-Debug "[outputs] - End" + Write-Debug '[outputs] - End' } From 7b6410e9203907f888045262620ae82064a70bc4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 10:44:50 +0100 Subject: [PATCH 05/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Comment=20out?= =?UTF-8?q?=20debug=20and=20verbose=20preferences=20in=20outputs.ps1=20for?= =?UTF-8?q?=20improved=20output=20control?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/outputs.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 index a10c5e3..b71bcfd 100644 --- a/scripts/outputs.ps1 +++ b/scripts/outputs.ps1 @@ -7,8 +7,8 @@ begin { process { try { - $DebugPreference = 'SilentlyContinue' - $VerbosePreference = 'SilentlyContinue' + # $DebugPreference = 'SilentlyContinue' + # $VerbosePreference = 'SilentlyContinue' Write-Debug "[outputs] - ShowOutput: $env:GITHUB_ACTION_INPUT_ShowOutput" if ($env:GITHUB_ACTION_INPUT_ShowOutput -ne 'true') { From dd765457047b5d5f631078c0a0a832a312b33723 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 12:13:17 +0100 Subject: [PATCH 06/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Adjust=20debug?= =?UTF-8?q?=20and=20verbose=20preferences=20in=20main.ps1=20for=20consiste?= =?UTF-8?q?nt=20output=20control?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 8d70554..7bf55c3 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -2,6 +2,8 @@ param() begin { + $DebugPreference = $env:GITHUB_ACTION_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue' + $VerbosePreference = $env:GITHUB_ACTION_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue' Write-Debug "[main] - Start" } @@ -94,8 +96,6 @@ process { Write-Host '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' - $DebugPreference = $env:GITHUB_ACTION_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue' - $VerbosePreference = $env:GITHUB_ACTION_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue' } end { From 909741d34881a57a2dc60756fb370f098d1ebe1c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 14:41:22 +0100 Subject: [PATCH 07/23] =?UTF-8?q?=F0=9F=AA=B2=20[Fix]:=20Update=20exit=20c?= =?UTF-8?q?odes=20in=20action.yml=20for=20improved=20error=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index c687895..767a515 100644 --- a/action.yml +++ b/action.yml @@ -70,12 +70,12 @@ runs: . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1') } catch { Write-Error $_ - exit 1 + exit 2 } ${{ inputs.Script }} try { . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1') } catch { Write-Error $_ - exit 1 + exit 3 } From 436a1e434c3fc3058003e5f963c26fd191fb12be Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 14:45:25 +0100 Subject: [PATCH 08/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Capture=20exit?= =?UTF-8?q?=20codes=20from=20main=20and=20outputs=20scripts=20in=20action.?= =?UTF-8?q?yml=20for=20improved=20error=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 767a515..e777306 100644 --- a/action.yml +++ b/action.yml @@ -67,15 +67,17 @@ runs: run: | # GitHub-Script try { - . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1') + $exit = . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1') } catch { Write-Error $_ exit 2 } ${{ inputs.Script }} try { - . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1') + $exit = . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1') } catch { Write-Error $_ exit 3 } + $exit + Write-Host 'What about this' From fe21819fb92155484bc2abd72b1f94e9a0609c6d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 14:52:04 +0100 Subject: [PATCH 09/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Comment=20out?= =?UTF-8?q?=20script=20execution=20and=20error=20handling=20in=20action.ym?= =?UTF-8?q?l=20for=20debugging=20purposes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index e777306..1039efb 100644 --- a/action.yml +++ b/action.yml @@ -73,11 +73,11 @@ runs: exit 2 } ${{ inputs.Script }} - try { - $exit = . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1') - } catch { - Write-Error $_ - exit 3 - } - $exit + # try { + # $exit = . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1') + # } catch { + # Write-Error $_ + # exit 3 + # } + # $exit Write-Host 'What about this' From 22689458e97c4dcfdec55a603e9d13d3916f51d8 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 14:53:43 +0100 Subject: [PATCH 10/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Comment=20out?= =?UTF-8?q?=20script=20execution=20and=20error=20handling=20in=20action.ym?= =?UTF-8?q?l=20for=20debugging=20purposes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 1039efb..bbbd1ce 100644 --- a/action.yml +++ b/action.yml @@ -66,12 +66,12 @@ runs: GITHUB_ACTION_INPUT_Prerelease: ${{ inputs.Prerelease }} run: | # GitHub-Script - try { - $exit = . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1') - } catch { - Write-Error $_ - exit 2 - } + # try { + # $exit = . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1') + # } catch { + # Write-Error $_ + # exit 2 + # } ${{ inputs.Script }} # try { # $exit = . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1') From 7517b296f42f8f25383c00eb7fe9a9014bc7308c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 14:54:52 +0100 Subject: [PATCH 11/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Uncomment=20scr?= =?UTF-8?q?ipt=20execution=20in=20action.yml=20for=20improved=20functional?= =?UTF-8?q?ity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index bbbd1ce..dcc2651 100644 --- a/action.yml +++ b/action.yml @@ -66,12 +66,8 @@ runs: GITHUB_ACTION_INPUT_Prerelease: ${{ inputs.Prerelease }} run: | # GitHub-Script - # try { - # $exit = . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1') - # } catch { - # Write-Error $_ - # exit 2 - # } + . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1') + ${{ inputs.Script }} # try { # $exit = . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1') From 584a97d56eee9e7e9e0c881725f341e45cc29525 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 14:55:27 +0100 Subject: [PATCH 12/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Refactor=20main?= =?UTF-8?q?.ps1=20for=20improved=20error=20handling=20and=20debugging=20cl?= =?UTF-8?q?arity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 155 ++++++++++++++++++++++++----------------------- 1 file changed, 79 insertions(+), 76 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 7bf55c3..cb6446b 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -4,100 +4,103 @@ param() begin { $DebugPreference = $env:GITHUB_ACTION_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue' $VerbosePreference = $env:GITHUB_ACTION_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue' - Write-Debug "[main] - Start" + Write-Debug '[main] - Start' } process { - $env:PSMODULE_GITHUB_SCRIPT = $true - Write-Host '┏━━━━━┫ GitHub-Script ┣━━━━━┓' - Write-Host '::group:: - Setup GitHub PowerShell' + try { + $env:PSMODULE_GITHUB_SCRIPT = $true + Write-Host '┏━━━━━┫ GitHub-Script ┣━━━━━┓' + Write-Host '::group:: - Setup GitHub PowerShell' - $Name = 'GitHub' - $Version = [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Version) ? $null : $env:GITHUB_ACTION_INPUT_Version - $Prerelease = $env:GITHUB_ACTION_INPUT_Prerelease -eq 'true' + $Name = 'GitHub' + $Version = [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Version) ? $null : $env:GITHUB_ACTION_INPUT_Version + $Prerelease = $env:GITHUB_ACTION_INPUT_Prerelease -eq 'true' - $alreadyInstalled = Get-InstalledPSResource -Name $Name -ErrorAction SilentlyContinue - if ($Version) { - Write-Verbose "Filtering by version: $Version" - $alreadyInstalled = $alreadyInstalled | Where-Object Version -EQ $Version - } - if ($Prerelease) { - Write-Verbose 'Filtering by prerelease' - $alreadyInstalled = $alreadyInstalled | Where-Object Prerelease -EQ $Prerelease - } - Write-Verbose 'Already installed:' - $alreadyInstalled | Format-Table - if (-not $alreadyInstalled) { - $params = @{ - Name = $Name - Repository = 'PSGallery' - TrustRepository = $true - Prerelease = $Prerelease - } + $alreadyInstalled = Get-InstalledPSResource -Name $Name -ErrorAction SilentlyContinue if ($Version) { - $params['Version'] = $Version + Write-Verbose "Filtering by version: $Version" + $alreadyInstalled = $alreadyInstalled | Where-Object Version -EQ $Version } - $Count = 5 - $Delay = 10 - for ($i = 1; $i -le $Count; $i++) { - try { - Install-PSResource @params - break - } catch { - if ($i -eq $Count) { - throw $_ + if ($Prerelease) { + Write-Verbose 'Filtering by prerelease' + $alreadyInstalled = $alreadyInstalled | Where-Object Prerelease -EQ $Prerelease + } + Write-Verbose 'Already installed:' + $alreadyInstalled | Format-Table + if (-not $alreadyInstalled) { + $params = @{ + Name = $Name + Repository = 'PSGallery' + TrustRepository = $true + Prerelease = $Prerelease + } + if ($Version) { + $params['Version'] = $Version + } + $Count = 5 + $Delay = 10 + for ($i = 1; $i -le $Count; $i++) { + try { + Install-PSResource @params + break + } catch { + if ($i -eq $Count) { + throw $_ + } + Start-Sleep -Seconds $Delay } - Start-Sleep -Seconds $Delay } } - } - - $alreadyImported = Get-Module -Name $Name - Write-Verbose 'Already imported:' - $alreadyImported | Format-Table - if (-not $alreadyImported) { - Write-Verbose "Importing module: $Name" - Import-Module -Name $Name - } - $providedToken = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Token) - $providedClientID = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_ClientID) - $providedPrivateKey = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_PrivateKey) - [pscustomobject]@{ - Name = $Name - Version = [string]::IsNullOrEmpty($Version) ? 'latest' : $Version - Prerelease = $Prerelease - 'Already installed' = $null -ne $alreadyInstalled - 'Already imported' = $null -ne $alreadyImported - 'Provided Token' = $providedToken - 'Provided ClientID' = $providedClientID - 'Provided PrivateKey' = $providedPrivateKey - } | Format-List - Write-Host '::endgroup::' + $alreadyImported = Get-Module -Name $Name + Write-Verbose 'Already imported:' + $alreadyImported | Format-Table + if (-not $alreadyImported) { + Write-Verbose "Importing module: $Name" + Import-Module -Name $Name + } - LogGroup ' - Installed modules' { - Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Sort-Object -Property Name | Format-Table -AutoSize - } + $providedToken = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Token) + $providedClientID = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_ClientID) + $providedPrivateKey = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_PrivateKey) + [pscustomobject]@{ + Name = $Name + Version = [string]::IsNullOrEmpty($Version) ? 'latest' : $Version + Prerelease = $Prerelease + 'Already installed' = $null -ne $alreadyInstalled + 'Already imported' = $null -ne $alreadyImported + 'Provided Token' = $providedToken + 'Provided ClientID' = $providedClientID + 'Provided PrivateKey' = $providedPrivateKey + } | Format-List + Write-Host '::endgroup::' - LogGroup ' - GitHub connection' { - if ($providedClientID -and $providedPrivateKey) { - Write-Verbose 'Connected using provided GitHub App' - Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent - } elseif ($providedToken) { - Write-Verbose 'Connected using provided token' - Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent + LogGroup ' - Installed modules' { + Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Sort-Object -Property Name | Format-Table -AutoSize } - Get-GitHubContext | Format-List - } - LogGroup ' - Configuration' { - Get-GitHubConfig | Format-List - } + LogGroup ' - GitHub connection' { + if ($providedClientID -and $providedPrivateKey) { + Write-Verbose 'Connected using provided GitHub App' + Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent + } elseif ($providedToken) { + Write-Verbose 'Connected using provided token' + Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent + } + Get-GitHubContext | Format-List + } - Write-Host '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' + LogGroup ' - Configuration' { + Get-GitHubConfig | Format-List + } + Write-Host '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' + } catch { + throw $_ + } } end { - Write-Debug "[main] - End" + Write-Debug '[main] - End' } From 6a7f31920b4e06491fdf13dd2114c96da513a35f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 14:57:51 +0100 Subject: [PATCH 13/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Comment=20out?= =?UTF-8?q?=20logging=20groups=20in=20main.ps1=20for=20debugging=20purpose?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index cb6446b..c4ae02d 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -76,24 +76,24 @@ process { } | Format-List Write-Host '::endgroup::' - LogGroup ' - Installed modules' { - Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Sort-Object -Property Name | Format-Table -AutoSize - } + # LogGroup ' - Installed modules' { + # Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Sort-Object -Property Name | Format-Table -AutoSize + # } - LogGroup ' - GitHub connection' { - if ($providedClientID -and $providedPrivateKey) { - Write-Verbose 'Connected using provided GitHub App' - Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent - } elseif ($providedToken) { - Write-Verbose 'Connected using provided token' - Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent - } - Get-GitHubContext | Format-List - } + # LogGroup ' - GitHub connection' { + # if ($providedClientID -and $providedPrivateKey) { + # Write-Verbose 'Connected using provided GitHub App' + # Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent + # } elseif ($providedToken) { + # Write-Verbose 'Connected using provided token' + # Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent + # } + # Get-GitHubContext | Format-List + # } - LogGroup ' - Configuration' { - Get-GitHubConfig | Format-List - } + # LogGroup ' - Configuration' { + # Get-GitHubConfig | Format-List + # } Write-Host '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' } catch { From 27090c61ef43e3cbb6a78a5370cf1853f53eb484 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 15:00:05 +0100 Subject: [PATCH 14/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Uncomment=20log?= =?UTF-8?q?ging=20for=20installed=20modules=20in=20main.ps1=20to=20enhance?= =?UTF-8?q?=20visibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index c4ae02d..ceb1ba8 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -76,9 +76,9 @@ process { } | Format-List Write-Host '::endgroup::' - # LogGroup ' - Installed modules' { - # Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Sort-Object -Property Name | Format-Table -AutoSize - # } + LogGroup ' - Installed modules' { + Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Sort-Object -Property Name | Format-Table -AutoSize + } # LogGroup ' - GitHub connection' { # if ($providedClientID -and $providedPrivateKey) { From 2a23504f0a1a42205d3a47a90a334bd51539c0f3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 15:01:18 +0100 Subject: [PATCH 15/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Uncomment=20Git?= =?UTF-8?q?Hub=20connection=20logging=20in=20main.ps1=20for=20enhanced=20v?= =?UTF-8?q?isibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index ceb1ba8..1704d00 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -80,16 +80,16 @@ process { Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Sort-Object -Property Name | Format-Table -AutoSize } - # LogGroup ' - GitHub connection' { - # if ($providedClientID -and $providedPrivateKey) { - # Write-Verbose 'Connected using provided GitHub App' - # Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent - # } elseif ($providedToken) { - # Write-Verbose 'Connected using provided token' - # Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent - # } - # Get-GitHubContext | Format-List - # } + LogGroup ' - GitHub connection' { + if ($providedClientID -and $providedPrivateKey) { + Write-Verbose 'Connected using provided GitHub App' + Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent + } elseif ($providedToken) { + Write-Verbose 'Connected using provided token' + Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent + } + Get-GitHubContext | Format-List + } # LogGroup ' - Configuration' { # Get-GitHubConfig | Format-List From a63be7ec4462edbdb1a24792cc918349f5491dfa Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 15:03:54 +0100 Subject: [PATCH 16/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Uncomment=20Git?= =?UTF-8?q?Hub=20connection=20logging=20in=20main.ps1=20for=20improved=20v?= =?UTF-8?q?isibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 1704d00..2548c59 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -80,21 +80,21 @@ process { Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Sort-Object -Property Name | Format-Table -AutoSize } - LogGroup ' - GitHub connection' { - if ($providedClientID -and $providedPrivateKey) { - Write-Verbose 'Connected using provided GitHub App' - Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent - } elseif ($providedToken) { - Write-Verbose 'Connected using provided token' - Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent - } - Get-GitHubContext | Format-List - } - - # LogGroup ' - Configuration' { - # Get-GitHubConfig | Format-List + # LogGroup ' - GitHub connection' { + # if ($providedClientID -and $providedPrivateKey) { + # Write-Verbose 'Connected using provided GitHub App' + # Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent + # } elseif ($providedToken) { + # Write-Verbose 'Connected using provided token' + # Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent + # } + # Get-GitHubContext | Format-List # } + LogGroup ' - Configuration' { + Get-GitHubConfig | Format-List + } + Write-Host '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' } catch { throw $_ From 281a03960faa9f293d10b26f073773fe435866df Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 15:24:29 +0100 Subject: [PATCH 17/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Restore=20execu?= =?UTF-8?q?tion=20of=20outputs.ps1=20in=20action.yml=20for=20proper=20scri?= =?UTF-8?q?pt=20functionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/action.yml b/action.yml index dcc2651..5935e46 100644 --- a/action.yml +++ b/action.yml @@ -67,13 +67,5 @@ runs: run: | # GitHub-Script . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1') - ${{ inputs.Script }} - # try { - # $exit = . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1') - # } catch { - # Write-Error $_ - # exit 3 - # } - # $exit - Write-Host 'What about this' + . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1') From 5226772f2108598fcd34010dac1d0beecd78ffbc Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 15:25:15 +0100 Subject: [PATCH 18/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Uncomment=20Git?= =?UTF-8?q?Hub=20connection=20logging=20in=20main.ps1=20for=20improved=20f?= =?UTF-8?q?unctionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 2548c59..cb6446b 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -80,16 +80,16 @@ process { Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Sort-Object -Property Name | Format-Table -AutoSize } - # LogGroup ' - GitHub connection' { - # if ($providedClientID -and $providedPrivateKey) { - # Write-Verbose 'Connected using provided GitHub App' - # Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent - # } elseif ($providedToken) { - # Write-Verbose 'Connected using provided token' - # Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent - # } - # Get-GitHubContext | Format-List - # } + LogGroup ' - GitHub connection' { + if ($providedClientID -and $providedPrivateKey) { + Write-Verbose 'Connected using provided GitHub App' + Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent + } elseif ($providedToken) { + Write-Verbose 'Connected using provided token' + Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent + } + Get-GitHubContext | Format-List + } LogGroup ' - Configuration' { Get-GitHubConfig | Format-List From e976c9afe009fdaabf0f846cbbd965083a8d0d1e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 15:36:36 +0100 Subject: [PATCH 19/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Refactor=20GitH?= =?UTF-8?q?ub=20connection=20logging=20in=20main.ps1=20for=20improved=20cl?= =?UTF-8?q?arity=20and=20functionality?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index cb6446b..d0380ab 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -80,15 +80,17 @@ process { Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Sort-Object -Property Name | Format-Table -AutoSize } - LogGroup ' - GitHub connection' { - if ($providedClientID -and $providedPrivateKey) { - Write-Verbose 'Connected using provided GitHub App' - Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent - } elseif ($providedToken) { - Write-Verbose 'Connected using provided token' - Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent + if ($providedToken -or ($providedClientID -and $providedPrivateKey)) { + LogGroup ' - GitHub connection' { + if ($providedClientID -and $providedPrivateKey) { + Write-Verbose 'Connected using provided GitHub App' + Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent + } elseif ($providedToken) { + Write-Verbose 'Connected using provided token' + Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent + } + Get-GitHubContext | Format-List } - Get-GitHubContext | Format-List } LogGroup ' - Configuration' { From bdc6fbb9cad9e05e4a26374b9c0ba2334ee95663 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 15:40:57 +0100 Subject: [PATCH 20/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Simplify=20GitH?= =?UTF-8?q?ub=20connection=20logging=20in=20main.ps1=20for=20improved=20cl?= =?UTF-8?q?arity=20and=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index d0380ab..ff47ced 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -80,16 +80,15 @@ process { Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Sort-Object -Property Name | Format-Table -AutoSize } - if ($providedToken -or ($providedClientID -and $providedPrivateKey)) { - LogGroup ' - GitHub connection' { - if ($providedClientID -and $providedPrivateKey) { - Write-Verbose 'Connected using provided GitHub App' - Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent - } elseif ($providedToken) { - Write-Verbose 'Connected using provided token' - Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent - } - Get-GitHubContext | Format-List + if ($providedClientID -and $providedPrivateKey) { + LogGroup ' - GitHub connection - GitHub App' { + Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent -PassThru | + Format-List + } + } elseif ($providedToken) { + LogGroup ' - GitHub connection - Token' { + Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent -PassThru | + Format-List } } From a5f1b9d77e4e243cf7e891fa8201c4121c55eed4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 16:44:35 +0100 Subject: [PATCH 21/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Enhance=20error?= =?UTF-8?q?=20handling=20in=20Install-PSResource=20call=20in=20main.ps1=20?= =?UTF-8?q?for=20improved=20reliability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index ff47ced..8d8b9cb 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -42,7 +42,7 @@ process { $Delay = 10 for ($i = 1; $i -le $Count; $i++) { try { - Install-PSResource @params + Install-PSResource @params -ErrorAction Stop break } catch { if ($i -eq $Count) { From 4a4224f7303d734c158e5d00deac9bfc784fde96 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 16:47:38 +0100 Subject: [PATCH 22/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Enable=20debug?= =?UTF-8?q?=20and=20verbose=20preferences=20in=20outputs.ps1=20for=20enhan?= =?UTF-8?q?ced=20logging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/outputs.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 index b71bcfd..a10c5e3 100644 --- a/scripts/outputs.ps1 +++ b/scripts/outputs.ps1 @@ -7,8 +7,8 @@ begin { process { try { - # $DebugPreference = 'SilentlyContinue' - # $VerbosePreference = 'SilentlyContinue' + $DebugPreference = 'SilentlyContinue' + $VerbosePreference = 'SilentlyContinue' Write-Debug "[outputs] - ShowOutput: $env:GITHUB_ACTION_INPUT_ShowOutput" if ($env:GITHUB_ACTION_INPUT_ShowOutput -ne 'true') { From eaa01f92084a10a61b94bda939bf5caaf5703a23 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 11 Jan 2025 21:25:30 +0100 Subject: [PATCH 23/23] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Restore=20debug?= =?UTF-8?q?=20and=20verbose=20preferences=20in=20main.ps1=20and=20outputs.?= =?UTF-8?q?ps1=20for=20consistent=20logging=20behavior?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 5 +++-- scripts/outputs.ps1 | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 8d8b9cb..bc28c3c 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -2,8 +2,6 @@ param() begin { - $DebugPreference = $env:GITHUB_ACTION_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue' - $VerbosePreference = $env:GITHUB_ACTION_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue' Write-Debug '[main] - Start' } @@ -45,6 +43,7 @@ process { Install-PSResource @params -ErrorAction Stop break } catch { + Write-Warning $_.Exception.Message if ($i -eq $Count) { throw $_ } @@ -104,4 +103,6 @@ process { end { Write-Debug '[main] - End' + $DebugPreference = $env:GITHUB_ACTION_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue' + $VerbosePreference = $env:GITHUB_ACTION_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue' } diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 index a10c5e3..f847c4b 100644 --- a/scripts/outputs.ps1 +++ b/scripts/outputs.ps1 @@ -2,14 +2,13 @@ param() begin { + $DebugPreference = 'SilentlyContinue' + $VerbosePreference = 'SilentlyContinue' Write-Debug '[outputs] - Start' } process { try { - $DebugPreference = 'SilentlyContinue' - $VerbosePreference = 'SilentlyContinue' - Write-Debug "[outputs] - ShowOutput: $env:GITHUB_ACTION_INPUT_ShowOutput" if ($env:GITHUB_ACTION_INPUT_ShowOutput -ne 'true') { return