From 081aac406b53f54e94e077f9cb49ce23432ed457 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 5 Jan 2025 20:21:52 +0100 Subject: [PATCH 01/10] Add log of outputs --- action.yml | 3 ++- scripts/outputs.ps1 | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 scripts/outputs.ps1 diff --git a/action.yml b/action.yml index 26a4163..6b1c136 100644 --- a/action.yml +++ b/action.yml @@ -61,5 +61,6 @@ runs: GITHUB_ACTION_INPUT_Prerelease: ${{ inputs.Prerelease }} run: | # GitHub-Script - . "${{ github.action_path }}\scripts\main.ps1" + . '${{ github.action_path }}\scripts\main.ps1' ${{ inputs.Script }} + . '${{ github.action_path }}\scripts\outputs.ps1' diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 new file mode 100644 index 0000000..be2dca3 --- /dev/null +++ b/scripts/outputs.ps1 @@ -0,0 +1,22 @@ +[CmdletBinding()] +param() + +$DebugPreference = 'SilentlyContinue' +$VerbosePreference = 'SilentlyContinue' + +Write-Host '┏━━━━━┫ GitHub-Script ┣━━━━━┓' + +LogGroup ' - Outputs' { + if ([string]::IsNullOrEmpty($env:GITHUB_ACTION)) { + Write-Warning '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" + } + + Get-GitHubOutput | Format-List + Write-Host "Access outputs using `${{ fromJson(steps.$env:GITHUB_ACTION.outputs.result). }}" +} + +Write-Host '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' From f685e352a7486b3c00b2b11f3bb6d295619f4702 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 5 Jan 2025 20:26:45 +0100 Subject: [PATCH 02/10] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20output?= =?UTF-8?q?=20retrieval=20to=20access=20result=20directly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/outputs.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 index be2dca3..1d82d97 100644 --- a/scripts/outputs.ps1 +++ b/scripts/outputs.ps1 @@ -15,7 +15,7 @@ LogGroup ' - Outputs' { Write-Warning "File not found: $env:GITHUB_OUTPUT" } - Get-GitHubOutput | Format-List + (Get-GitHubOutput).result | Format-List Write-Host "Access outputs using `${{ fromJson(steps.$env:GITHUB_ACTION.outputs.result). }}" } From b47a03cef379edfaf3b1cccf9d272685c9da247d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 5 Jan 2025 20:55:10 +0100 Subject: [PATCH 03/10] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Optimize=20outp?= =?UTF-8?q?ut=20retrieval=20and=20improve=20warning=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/outputs.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 index 1d82d97..1d96a9b 100644 --- a/scripts/outputs.ps1 +++ b/scripts/outputs.ps1 @@ -4,18 +4,23 @@ param() $DebugPreference = 'SilentlyContinue' $VerbosePreference = 'SilentlyContinue' +$result = (Get-GitHubOutput).result +if (-not $result) { + return +} + Write-Host '┏━━━━━┫ GitHub-Script ┣━━━━━┓' LogGroup ' - Outputs' { if ([string]::IsNullOrEmpty($env:GITHUB_ACTION)) { - Write-Warning 'Outputs cannot be accessed as the step has no ID.' + 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" } - (Get-GitHubOutput).result | Format-List + $result | Format-List Write-Host "Access outputs using `${{ fromJson(steps.$env:GITHUB_ACTION.outputs.result). }}" } From ea951f46217679c3fa2457029bd5ace70404e06b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 5 Jan 2025 21:03:22 +0100 Subject: [PATCH 04/10] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20raw=20UI?= =?UTF-8?q?=20output=20for=20GitHub=20PowerShell=20setup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index db873ff..b24902b 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -1,6 +1,9 @@ [CmdletBinding()] param() +$rawUI = $Host.UI.RawUI +$rawUI + $env:PSMODULE_GITHUB_SCRIPT = $true Write-Host "┏━━━━━┫ GitHub-Script ┣━━━━━┓" Write-Host '::group:: - Setup GitHub PowerShell' From 12848308685bb25bd7286d5782d0621ff5c72f70 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 5 Jan 2025 21:06:50 +0100 Subject: [PATCH 05/10] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20raw=20UI?= =?UTF-8?q?=20window=20and=20buffer=20size=20output=20to=20main=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index b24902b..f719a45 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -4,6 +4,9 @@ param() $rawUI = $Host.UI.RawUI $rawUI +$rawUI.WindowSize +$rawUI.BufferSize + $env:PSMODULE_GITHUB_SCRIPT = $true Write-Host "┏━━━━━┫ GitHub-Script ┣━━━━━┓" Write-Host '::group:: - Setup GitHub PowerShell' From aef88c7606c2347e5daa43299e8b9f9d3aec26c4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 5 Jan 2025 21:08:57 +0100 Subject: [PATCH 06/10] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Set=20fixed=20w?= =?UTF-8?q?indow=20and=20buffer=20size=20for=20raw=20UI=20in=20main=20scri?= =?UTF-8?q?pt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index f719a45..35efce8 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -1,11 +1,8 @@ [CmdletBinding()] param() -$rawUI = $Host.UI.RawUI -$rawUI - -$rawUI.WindowSize -$rawUI.BufferSize +$rawUI.WindowSize.Width = 500 +$rawUI.BufferSize.Width = 500 $env:PSMODULE_GITHUB_SCRIPT = $true Write-Host "┏━━━━━┫ GitHub-Script ┣━━━━━┓" From a3d7834b1ba63e948a2fd3dbac364653cbd730ce Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 5 Jan 2025 21:10:08 +0100 Subject: [PATCH 07/10] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20raw=20?= =?UTF-8?q?UI=20access=20method=20for=20window=20and=20buffer=20size=20in?= =?UTF-8?q?=20main=20script?= 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 35efce8..95b46bf 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -1,8 +1,8 @@ [CmdletBinding()] param() -$rawUI.WindowSize.Width = 500 -$rawUI.BufferSize.Width = 500 +$Host.UI.RawUI.WindowSize.Width = 500 +$Host.UI.RawUI.BufferSize.Width = 500 $env:PSMODULE_GITHUB_SCRIPT = $true Write-Host "┏━━━━━┫ GitHub-Script ┣━━━━━┓" From b857b0ad51eb90ca8dd1fb3f52d95b0167e15fcb Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 5 Jan 2025 21:59:46 +0100 Subject: [PATCH 08/10] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20ShowOutpu?= =?UTF-8?q?t=20input=20to=20action=20and=20update=20output=20script=20logi?= =?UTF-8?q?c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +++- action.yml | 13 +++++++++---- scripts/outputs.ps1 | 4 ++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4bb7d83..a6a7a9e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ A GitHub Action used for running a PowerShell Script that uses the GitHub PowerShell module. -For more information on the available functions and automatic loaded variables, see the [GitHub PowerShell module documentation](https://psmodule.io/GitHub) +For more information on the available functions and automatic loaded variables, see the +[GitHub PowerShell module documentation](https://psmodule.io/GitHub) ## Usage @@ -18,6 +19,7 @@ For more information on the available functions and automatic loaded variables, | `Verbose` | Enable verbose output. | false | `'false'` | | `Version` | Specifies the version of the GitHub module to be installed. The value must be an exact version. | false | | | `Prerelease` | Allow prerelease versions if available. | false | `'false'` | +| `ShowOutput` | Show the output of the script. | false | `'false'` | | `WorkingDirectory` | The working directory where the script will run from. | false | `${{ github.workspace }}` | ### Outputs diff --git a/action.yml b/action.yml index 6b1c136..5875e2e 100644 --- a/action.yml +++ b/action.yml @@ -34,6 +34,10 @@ inputs: description: Allow prerelease versions if available. required: false default: 'false' + ShowOutput: + description: Show the output of the script. + required: false + default: 'false' WorkingDirectory: description: The working directory where the script will run from. required: false @@ -42,14 +46,14 @@ inputs: outputs: result: description: The output of the script as a JSON object. To add outputs to `result`, use `Set-GitHubOutput`. - value: ${{ steps.RunGitGubScript.outputs.result }} + value: ${{ steps.RunGitHubScript.outputs.result }} runs: using: composite steps: - name: Install GitHub shell: pwsh - id: RunGitGubScript + id: RunGitHubScript working-directory: ${{ inputs.WorkingDirectory }} env: GITHUB_ACTION_INPUT_Token: ${{ inputs.Token }} @@ -58,9 +62,10 @@ runs: GITHUB_ACTION_INPUT_Debug: ${{ inputs.Debug }} GITHUB_ACTION_INPUT_Verbose: ${{ inputs.Verbose }} GITHUB_ACTION_INPUT_Version: ${{ inputs.Version }} + GITHUB_ACTION_INPUT_ShowOutput: ${{ inputs.ShowOutput }} GITHUB_ACTION_INPUT_Prerelease: ${{ inputs.Prerelease }} run: | # GitHub-Script - . '${{ github.action_path }}\scripts\main.ps1' + . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1' ${{ inputs.Script }} - . '${{ github.action_path }}\scripts\outputs.ps1' + . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1' diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 index 1d96a9b..f067d6a 100644 --- a/scripts/outputs.ps1 +++ b/scripts/outputs.ps1 @@ -4,6 +4,10 @@ param() $DebugPreference = 'SilentlyContinue' $VerbosePreference = 'SilentlyContinue' +if ($env:GITHUB_ACTION_INPUT_ShowOutput -ne 'true') { + return +} + $result = (Get-GitHubOutput).result if (-not $result) { return From 875558d6edc2a7d689f19246aff9973fe62416d1 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 5 Jan 2025 22:05:47 +0100 Subject: [PATCH 09/10] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20ShowOutpu?= =?UTF-8?q?t=20parameter=20to=20action=20and=20update=20summary=20retrieva?= =?UTF-8?q?l=20in=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index d60f839..72445dd 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -68,6 +68,7 @@ jobs: Debug: true Verbose: true Prerelease: true + ShowOutput: true Script: | $cat = Get-GitHubOctocat $zen = Get-GitHubZen @@ -79,9 +80,10 @@ jobs: shell: pwsh env: result: ${{ steps.test.outputs.result }} + WISECAT: ${{ fromJson(steps.test.outputs.result).WISECAT }} run: | $result = $env:result | ConvertFrom-Json - Set-GitHubStepSummary -Summary $result.WISECAT + Set-GitHubStepSummary -Summary $env:WISECAT Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen' ActionTestWithoutToken: From 6e3df538276489f942897839ff0faf509edb22d1 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 5 Jan 2025 22:09:44 +0100 Subject: [PATCH 10/10] Fix --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 5875e2e..5935e46 100644 --- a/action.yml +++ b/action.yml @@ -66,6 +66,6 @@ runs: GITHUB_ACTION_INPUT_Prerelease: ${{ inputs.Prerelease }} run: | # GitHub-Script - . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1' + . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1') ${{ inputs.Script }} - . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1' + . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1')