Skip to content

Commit a20efdd

Browse files
committed
20220703A
1 parent d63baf2 commit a20efdd

File tree

4 files changed

+101
-117
lines changed

4 files changed

+101
-117
lines changed

hugoalh.GitHubActionsToolkit/module/log.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Function Enter-LogGroup {
2828
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_enter-githubactionsloggroup#Enter-GitHubActionsLogGroup')]
2929
[OutputType([Void])]
3030
Param (
31-
[Parameter(Mandatory = $True, Position = 0)][ValidatePattern('^.+$', ErrorMessage = 'Parameter `Title` must be in single line string!')][Alias('Header')][String]$Title
31+
[Parameter(Mandatory = $True, Position = 0)][ValidatePattern('^.+$', ErrorMessage = 'Parameter `Title` must be in single line string!')][Alias('Header', 'Summary')][String]$Title
3232
)
3333
Write-GitHubActionsCommand -Command 'group' -Value $Title
3434
}

hugoalh.GitHubActionsToolkit/module/parameter.psm1

Lines changed: 97 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Function Get-Input {
3434
[OutputType([String], ParameterSetName = 'One')]
3535
[OutputType([Hashtable], ParameterSetName = ('All', 'Prefix', 'Suffix'))]
3636
Param (
37-
[Parameter(Mandatory = $True, ParameterSetName = 'One', Position = 0, ValueFromPipeline = $True)][ValidatePattern('^(?:[\da-z][\da-z_-]*)?[\da-z]$', ErrorMessage = '`{0}` is not a valid GitHub Actions input name!')][Alias('Key')][String]$Name,
37+
[Parameter(Mandatory = $True, ParameterSetName = 'One', Position = 0)][ValidatePattern('^(?:[\da-z][\da-z_-]*)?[\da-z]$', ErrorMessage = '`{0}` is not a valid GitHub Actions input name!')][Alias('Key')][String]$Name,
3838
[Parameter(ParameterSetName = 'One')][Alias('Require', 'Required')][Switch]$Mandatory,
3939
[Parameter(ParameterSetName = 'One')][Alias('RequiredMessage', 'RequireMessage')][String]$MandatoryMessage = 'Input `{0}` is not defined!',
4040
[Parameter(Mandatory = $True, ParameterSetName = 'All')][Switch]$All,
@@ -43,76 +43,68 @@ Function Get-Input {
4343
[Alias('AssumeEmptyStringAsNull')][Switch]$EmptyStringAsNull,
4444
[Switch]$Trim
4545
)
46-
Begin {
47-
[Hashtable]$OutputObject = @{}
48-
}
49-
Process {
50-
Switch ($PSCmdlet.ParameterSetName) {
51-
'All' {
52-
ForEach ($Item In (Get-ChildItem -Path 'Env:\INPUT_*')) {
53-
If ($Null -ieq $Item.Value) {
54-
Continue
55-
}
56-
[String]$ItemValue = $Trim.IsPresent ? $Item.Value.Trim() : $Item.Value
57-
If ($EmptyStringAsNull.IsPresent -and $ItemValue.Length -ieq 0) {
58-
Continue
59-
}
60-
[String]$ItemName = $Item.Name -ireplace '^INPUT_', ''
61-
$OutputObject[$ItemName] = $ItemValue
46+
[Hashtable]$OutputObject = @{}
47+
Switch ($PSCmdlet.ParameterSetName) {
48+
'All' {
49+
ForEach ($Item In (Get-ChildItem -Path 'Env:\INPUT_*')) {
50+
If ($Null -ieq $Item.Value) {
51+
Continue
6252
}
63-
}
64-
'One' {
65-
$InputValueRaw = Get-Content -LiteralPath "Env:\INPUT_$($Name.ToUpper())" -ErrorAction 'SilentlyContinue'
66-
If ($Null -ieq $InputValueRaw) {
67-
If ($Mandatory.IsPresent) {
68-
Write-GitHubActionsFail -Message ($MandatoryMessage -f $Name)
69-
Return
70-
}
71-
Return $Null
53+
[String]$ItemValue = $Trim.IsPresent ? $Item.Value.Trim() : $Item.Value
54+
If ($EmptyStringAsNull.IsPresent -and $ItemValue.Length -ieq 0) {
55+
Continue
7256
}
73-
[String]$InputValue = $Trim.IsPresent ? $InputValueRaw.Trim() : $InputValueRaw
74-
If ($EmptyStringAsNull.IsPresent -and $InputValue.Length -ieq 0) {
75-
If ($Mandatory.IsPresent) {
76-
Write-GitHubActionsFail -Message ($MandatoryMessage -f $Name)
77-
Return
78-
}
79-
Return $Null
57+
[String]$ItemName = $Item.Name -ireplace '^INPUT_', ''
58+
$OutputObject[$ItemName] = $ItemValue
59+
}
60+
}
61+
'One' {
62+
$InputValueRaw = Get-Content -LiteralPath "Env:\INPUT_$($Name.ToUpper())" -ErrorAction 'SilentlyContinue'
63+
If ($Null -ieq $InputValueRaw) {
64+
If ($Mandatory.IsPresent) {
65+
Write-GitHubActionsFail -Message ($MandatoryMessage -f $Name)
66+
Return
8067
}
81-
Return $InputValue
68+
Return $Null
8269
}
83-
'Prefix' {
84-
ForEach ($Item In (Get-ChildItem -Path "Env:\INPUT_$($NamePrefix.ToUpper())*")) {
85-
If ($Null -ieq $Item.Value) {
86-
Continue
87-
}
88-
[String]$ItemValue = $Trim.IsPresent ? $Item.Value.Trim() : $Item.Value
89-
If ($EmptyStringAsNull.IsPresent -and $ItemValue.Length -ieq 0) {
90-
Continue
91-
}
92-
[String]$ItemName = $Item.Name -ireplace "^INPUT_$([RegEx]::Escape($NamePrefix))", ''
93-
$OutputObject[$ItemName] = $ItemValue
70+
[String]$InputValue = $Trim.IsPresent ? $InputValueRaw.Trim() : $InputValueRaw
71+
If ($EmptyStringAsNull.IsPresent -and $InputValue.Length -ieq 0) {
72+
If ($Mandatory.IsPresent) {
73+
Write-GitHubActionsFail -Message ($MandatoryMessage -f $Name)
74+
Return
9475
}
76+
Return $Null
9577
}
96-
'Suffix' {
97-
ForEach ($Item In (Get-ChildItem -Path "Env:\INPUT_*$($NameSuffix.ToUpper())")) {
98-
If ($Null -ieq $Item.Value) {
99-
Continue
100-
}
101-
[String]$ItemValue = $Trim.IsPresent ? $Item.Value.Trim() : $Item.Value
102-
If ($EmptyStringAsNull.IsPresent -and $ItemValue.Length -ieq 0) {
103-
Continue
104-
}
105-
[String]$ItemName = $Item.Name -ireplace "^INPUT_|$([RegEx]::Escape($NameSuffix))$", ''
106-
$OutputObject[$ItemName] = $ItemValue
78+
Return $InputValue
79+
}
80+
'Prefix' {
81+
ForEach ($Item In (Get-ChildItem -Path "Env:\INPUT_$($NamePrefix.ToUpper())*")) {
82+
If ($Null -ieq $Item.Value) {
83+
Continue
84+
}
85+
[String]$ItemValue = $Trim.IsPresent ? $Item.Value.Trim() : $Item.Value
86+
If ($EmptyStringAsNull.IsPresent -and $ItemValue.Length -ieq 0) {
87+
Continue
10788
}
89+
[String]$ItemName = $Item.Name -ireplace "^INPUT_$([RegEx]::Escape($NamePrefix))", ''
90+
$OutputObject[$ItemName] = $ItemValue
10891
}
10992
}
110-
}
111-
End {
112-
If ($PSCmdlet.ParameterSetName -iin @('All', 'Prefix', 'Suffix')) {
113-
Return $OutputObject
93+
'Suffix' {
94+
ForEach ($Item In (Get-ChildItem -Path "Env:\INPUT_*$($NameSuffix.ToUpper())")) {
95+
If ($Null -ieq $Item.Value) {
96+
Continue
97+
}
98+
[String]$ItemValue = $Trim.IsPresent ? $Item.Value.Trim() : $Item.Value
99+
If ($EmptyStringAsNull.IsPresent -and $ItemValue.Length -ieq 0) {
100+
Continue
101+
}
102+
[String]$ItemName = $Item.Name -ireplace "^INPUT_|$([RegEx]::Escape($NameSuffix))$", ''
103+
$OutputObject[$ItemName] = $ItemValue
104+
}
114105
}
115106
}
107+
Return $OutputObject
116108
}
117109
<#
118110
.SYNOPSIS
@@ -140,75 +132,67 @@ Function Get-State {
140132
[OutputType([String], ParameterSetName = 'One')]
141133
[OutputType([Hashtable], ParameterSetName = ('All', 'Prefix', 'Suffix'))]
142134
Param (
143-
[Parameter(Mandatory = $True, ParameterSetName = 'One', Position = 0, ValueFromPipeline = $True)][ValidatePattern('^(?:[\da-z][\da-z_-]*)?[\da-z]$', ErrorMessage = '`{0}` is not a valid GitHub Actions state name!')][Alias('Key')][String]$Name,
135+
[Parameter(Mandatory = $True, ParameterSetName = 'One', Position = 0)][ValidatePattern('^(?:[\da-z][\da-z_-]*)?[\da-z]$', ErrorMessage = '`{0}` is not a valid GitHub Actions state name!')][Alias('Key')][String]$Name,
144136
[Parameter(Mandatory = $True, ParameterSetName = 'All')][Switch]$All,
145137
[Parameter(Mandatory = $True, ParameterSetName = 'Prefix')][ValidatePattern('^[\da-z][\da-z_-]*$', ErrorMessage = '`{0}` is not a valid GitHub Actions state name prefix!')][Alias('KeyPrefix', 'KeyStartWith', 'NameStartWith', 'Prefix', 'PrefixKey', 'PrefixName', 'StartWith', 'StartWithKey', 'StartWithName')][String]$NamePrefix,
146138
[Parameter(Mandatory = $True, ParameterSetName = 'Suffix')][ValidatePattern('^[\da-z_-]*[\da-z]$', ErrorMessage = '`{0}` is not a valid GitHub Actions state name suffix!')][Alias('EndWith', 'EndWithKey', 'EndWithName', 'KeyEndWith', 'KeySuffix', 'NameEndWith', 'Suffix', 'SuffixKey', 'SuffixName')][String]$NameSuffix,
147139
[Alias('AssumeEmptyStringAsNull')][Switch]$EmptyStringAsNull,
148140
[Switch]$Trim
149141
)
150-
Begin {
151-
[Hashtable]$OutputObject = @{}
152-
}
153-
Process {
154-
Switch ($PSCmdlet.ParameterSetName) {
155-
'All' {
156-
ForEach ($Item In (Get-ChildItem -Path 'Env:\STATE_*')) {
157-
If ($Null -ieq $Item.Value) {
158-
Continue
159-
}
160-
[String]$ItemValue = $Trim.IsPresent ? $Item.Value.Trim() : $Item.Value
161-
If ($EmptyStringAsNull.IsPresent -and $ItemValue.Length -ieq 0) {
162-
Continue
163-
}
164-
[String]$ItemName = $Item.Name -ireplace '^STATE_', ''
165-
$OutputObject[$ItemName] = $ItemValue
142+
[Hashtable]$OutputObject = @{}
143+
Switch ($PSCmdlet.ParameterSetName) {
144+
'All' {
145+
ForEach ($Item In (Get-ChildItem -Path 'Env:\STATE_*')) {
146+
If ($Null -ieq $Item.Value) {
147+
Continue
148+
}
149+
[String]$ItemValue = $Trim.IsPresent ? $Item.Value.Trim() : $Item.Value
150+
If ($EmptyStringAsNull.IsPresent -and $ItemValue.Length -ieq 0) {
151+
Continue
166152
}
153+
[String]$ItemName = $Item.Name -ireplace '^STATE_', ''
154+
$OutputObject[$ItemName] = $ItemValue
155+
}
156+
}
157+
'One' {
158+
$StateValueRaw = Get-Content -LiteralPath "Env:\STATE_$($Name.ToUpper())" -ErrorAction 'SilentlyContinue'
159+
If ($Null -ieq $StateValueRaw) {
160+
Return $Null
167161
}
168-
'One' {
169-
$StateValueRaw = Get-Content -LiteralPath "Env:\STATE_$($Name.ToUpper())" -ErrorAction 'SilentlyContinue'
170-
If ($Null -ieq $StateValueRaw) {
171-
Return $Null
162+
[String]$StateValue = $Trim.IsPresent ? $StateValueRaw.Trim() : $StateValueRaw
163+
If ($EmptyStringAsNull.IsPresent -and $StateValue.Length -ieq 0) {
164+
Return $Null
165+
}
166+
Return $StateValue
167+
}
168+
'Prefix' {
169+
ForEach ($Item In (Get-ChildItem -Path "Env:\STATE_$($NamePrefix.ToUpper())*")) {
170+
If ($Null -ieq $Item.Value) {
171+
Continue
172172
}
173-
[String]$StateValue = $Trim.IsPresent ? $StateValueRaw.Trim() : $StateValueRaw
174-
If ($EmptyStringAsNull.IsPresent -and $StateValue.Length -ieq 0) {
175-
Return $Null
173+
[String]$ItemValue = $Trim.IsPresent ? $Item.Value.Trim() : $Item.Value
174+
If ($EmptyStringAsNull.IsPresent -and $ItemValue.Length -ieq 0) {
175+
Continue
176176
}
177-
Return $StateValue
177+
[String]$ItemName = $Item.Name -ireplace "^STATE_$([RegEx]::Escape($NamePrefix))", ''
178+
$OutputObject[$ItemName] = $ItemValue
178179
}
179-
'Prefix' {
180-
ForEach ($Item In (Get-ChildItem -Path "Env:\STATE_$($NamePrefix.ToUpper())*")) {
181-
If ($Null -ieq $Item.Value) {
182-
Continue
183-
}
184-
[String]$ItemValue = $Trim.IsPresent ? $Item.Value.Trim() : $Item.Value
185-
If ($EmptyStringAsNull.IsPresent -and $ItemValue.Length -ieq 0) {
186-
Continue
187-
}
188-
[String]$ItemName = $Item.Name -ireplace "^STATE_$([RegEx]::Escape($NamePrefix))", ''
189-
$OutputObject[$ItemName] = $ItemValue
180+
}
181+
'Suffix' {
182+
ForEach ($Item In (Get-ChildItem -Path "Env:\STATE_*$($NameSuffix.ToUpper())")) {
183+
If ($Null -ieq $Item.Value) {
184+
Continue
190185
}
191-
}
192-
'Suffix' {
193-
ForEach ($Item In (Get-ChildItem -Path "Env:\STATE_*$($NameSuffix.ToUpper())")) {
194-
If ($Null -ieq $Item.Value) {
195-
Continue
196-
}
197-
[String]$ItemValue = $Trim.IsPresent ? $Item.Value.Trim() : $Item.Value
198-
If ($EmptyStringAsNull.IsPresent -and $ItemValue.Length -ieq 0) {
199-
Continue
200-
}
201-
[String]$ItemName = $Item.Name -ireplace "^STATE_|$([RegEx]::Escape($NameSuffix))$", ''
202-
$OutputObject[$ItemName] = $ItemValue
186+
[String]$ItemValue = $Trim.IsPresent ? $Item.Value.Trim() : $Item.Value
187+
If ($EmptyStringAsNull.IsPresent -and $ItemValue.Length -ieq 0) {
188+
Continue
203189
}
190+
[String]$ItemName = $Item.Name -ireplace "^STATE_|$([RegEx]::Escape($NameSuffix))$", ''
191+
$OutputObject[$ItemName] = $ItemValue
204192
}
205193
}
206194
}
207-
End {
208-
If ($PSCmdlet.ParameterSetName -iin @('All', 'Prefix', 'Suffix')) {
209-
Return $OutputObject
210-
}
211-
}
195+
Return $OutputObject
212196
}
213197
Set-Alias -Name 'Restore-State' -Value 'Get-State' -Option 'ReadOnly' -Scope 'Local'
214198
<#

hugoalh.GitHubActionsToolkit/module/problem-matcher.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Function Add-ProblemMatcher {
2525
Begin {}
2626
Process {
2727
($PSCmdlet.ParameterSetName -ieq 'LiteralPath') ? $LiteralPath : [String[]](Resolve-Path -Path $Path) | ForEach-Object -Process {
28-
Write-GitHubActionsCommand -Command 'add-matcher' -Value ($_ -ireplace '^\.[\\\/]', '' -ireplace '\\', '/')
28+
Write-GitHubActionsCommand -Command 'add-matcher' -Value ($_ -ireplace '^\.[\\/]', '' -ireplace '\\', '/')
2929
}
3030
}
3131
End {}

hugoalh.GitHubActionsToolkit/module/step-summary.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ Image title.
8585
.PARAMETER AlternativeText
8686
Image alternative text.
8787
.PARAMETER Width
88-
Image width.
88+
Image width, by pixels.
8989
.PARAMETER Height
90-
Image height.
90+
Image height, by pixels.
9191
.PARAMETER NoNewLine
9292
Do not add a new line or carriage return to the content, the string representations of the input objects are concatenated to form the output, no spaces or newlines are inserted between the output strings, no newline is added after the last output string.
9393
.OUTPUTS

0 commit comments

Comments
 (0)