Skip to content

Commit d5ee054

Browse files
🚀 [Feature]: Configure PowerShell ErrorView settings (#49)
## 🚀 New Feature: `ErrorView` Configuration This release introduces a new feature to configure the PowerShell `$ErrorView` variable in the GitHub Action. This also sets the default to `NormalView` whereas the default in PowerShell is `ConciseView`. `NormalView` provides more information that would be great to get when troubleshooting errors in GitHub workflows. Users can still override this by adding their own settings in the provided script or using the input to set a different value when building actions or workflows. #### Details * Introduced the `ErrorView` input in `action.yml`, including its description, default value (`'NormalView'`), and marking it as optional. * The input is mapped to the new environment variable `PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView` in the `action.yml` file. * The environment variable is validated using wildcard matching against a predefined list of valid views, applies the matched view setting. * Added a description for the new `ErrorView` option in the `README.md` file. This option allows users to configure the `$ErrorView` variable using full or partial names of valid views.
1 parent 23bc6b9 commit d5ee054

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ To get started with your own GitHub PowerShell based action, [create a new repos
1919
| `Verbose` | Enable verbose output. | false | `'false'` |
2020
| `Version` | Specifies the exact version of the GitHub module to install. | false | |
2121
| `Prerelease` | Allow prerelease versions if available. | false | `'false'` |
22+
| `ErrorView` | Configure the PowerShell `$ErrorView` variable. You can use full names ('NormalView', 'CategoryView', 'ConciseView', 'DetailedView'). It matches on partials. | false | `'NormalView'` |
2223
| `ShowInfo` | Show information about the environment. | false | `'true'` |
2324
| `ShowInit` | Show information about the initialization. | false | `'false'` |
2425
| `ShowOutput` | Show the script's output. | false | `'false'` |

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ inputs:
5050
description: Show the output of the script.
5151
required: false
5252
default: 'false'
53+
ErrorView:
54+
description: Configure the PowerShell `$ErrorView` variable. You can use full names ('NormalView', 'CategoryView', 'ConciseView', 'DetailedView'). It matches on partials.
55+
required: false
56+
default: 'NormalView'
5357
WorkingDirectory:
5458
description: The working directory where the script will run from.
5559
required: false
@@ -79,6 +83,7 @@ runs:
7983
PSMODULE_GITHUB_SCRIPT_INPUT_ShowInfo: ${{ inputs.ShowInfo }}
8084
PSMODULE_GITHUB_SCRIPT_INPUT_ShowOutput: ${{ inputs.ShowOutput }}
8185
PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
86+
PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
8287
run: |
8388
# ${{ inputs.Name }}
8489
try {

scripts/init.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ begin {
55
$scriptName = $MyInvocation.MyCommand.Name
66
Write-Debug "[$scriptName] - Start"
77
$PSStyle.OutputRendering = 'Ansi'
8+
9+
# Configure ErrorView based on input parameter
10+
if (-not [string]::IsNullOrEmpty($env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView)) {
11+
$validViews = @('NormalView', 'CategoryView', 'ConciseView', 'DetailedView')
12+
$errorViewSetting = $env:PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView
13+
14+
# Simply find the first validView that matches the input using wildcards
15+
$matchedView = $validViews | Where-Object { $_ -like "*$errorViewSetting*" } | Select-Object -First 1
16+
17+
if ($matchedView) {
18+
Write-Debug "[$scriptName] - Input [$errorViewSetting] matched with [$matchedView]"
19+
$ErrorView = $matchedView
20+
} else {
21+
Write-Warning "[$scriptName] - Invalid ErrorView value: [$errorViewSetting]. Using default."
22+
}
23+
}
824
}
925

1026
process {

0 commit comments

Comments
 (0)