Skip to content

Commit f4658ad

Browse files
committed
20230626B
1 parent ab0537e commit f4658ad

File tree

7 files changed

+48
-48
lines changed

7 files changed

+48
-48
lines changed

hugoalh.GitHubActionsToolkit/hugoalh.GitHubActionsToolkit.psd1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@
8181
'Expand-ToolCacheCompressedFile',
8282
'Export-Artifact',
8383
'Find-ToolCache',
84+
'Get-DebugStatus',
8485
'Get-Input',
85-
'Get-IsDebug',
8686
'Get-OpenIdConnectToken',
8787
'Get-State',
8888
'Get-StepSummary',
@@ -163,6 +163,8 @@
163163
'Expand-ToolCacheFile',
164164
'Export-Cache',
165165
'Get-Event',
166+
'Get-EventPayload',
167+
'Get-IsDebug',
166168
'Get-OidcToken',
167169
'Get-Payload',
168170
'Get-WebhookEvent',

hugoalh.GitHubActionsToolkit/module/log.psm1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,22 @@ Function Write-Annotation {
104104
}
105105
[Hashtable]$Property = @{}
106106
If ($File.Length -gt 0) {
107-
$Property['file'] = $File
107+
$Property.('file') = $File
108108
}
109109
If ($Line -gt 0) {
110-
$Property['line'] = $Line
110+
$Property.('line') = $Line
111111
}
112112
If ($Column -gt 0) {
113-
$Property['col'] = $Column
113+
$Property.('col') = $Column
114114
}
115115
If ($EndLine -gt 0) {
116-
$Property['endLine'] = $EndLine
116+
$Property.('endLine') = $EndLine
117117
}
118118
If ($EndColumn -gt 0) {
119-
$Property['endColumn'] = $EndColumn
119+
$Property.('endColumn') = $EndColumn
120120
}
121121
If ($Title.Length -gt 0) {
122-
$Property['title'] = $Title
122+
$Property.('title') = $Title
123123
}
124124
Write-GitHubActionsStdOutCommand -StdOutCommand $TypeRaw -Parameter $Property -Value $Message
125125
}

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Function Test-NodeJsEnvironment {
131131
[OutputType([Boolean])]
132132
Param (
133133
[Alias('Redo')][Switch]$Retest,
134-
[Alias('Reinstall', 'ReinstallDependency', 'ReinstallPackage', 'ReinstallPackages')][Switch]$ReinstallDependencies# Deprecated, keep as legacy.
134+
[Alias('Reinstall', 'ReinstallDependency', 'ReinstallPackage', 'ReinstallPackages')][Switch]$ReinstallDependencies# Deprecated.
135135
)
136136
If ($PSBoundParameters.ContainsKey('ReinstallDependencies')) {
137137
Write-Warning -Message 'Parameter `ReinstallDependencies` is deprecated and will remove in the future version!'

hugoalh.GitHubActionsToolkit/module/open-id-connect.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Function Get-OpenIdConnectToken {
2020
[OutputType([String])]
2121
Param (
2222
[Parameter(Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][String]$Audience,
23-
[Parameter(ValueFromPipelineByPropertyName = $True)][Alias('NodeJs', 'NodeJsWrapper', 'UseNodeJs')][Switch]$UseNodeJsWrapper# Deprecated, keep as legacy.
23+
[Parameter(ValueFromPipelineByPropertyName = $True)][Alias('NodeJs', 'NodeJsWrapper', 'UseNodeJs')][Switch]$UseNodeJsWrapper# Deprecated.
2424
)
2525
Process {
2626
If ($PSBoundParameters.ContainsKey('UseNodeJsWrapper')) {

hugoalh.GitHubActionsToolkit/module/step-summary.psm1

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Requires -PSEdition Core -Version 7.2
2-
Class GitHubActionsStepSummary {
2+
Class GitHubActionsStepSummary {# Unstable, not in use yet.
33
Static [Hashtable[]]EscapeMarkdownCharactersList() {
44
Return @(
55
@{ Pattern = '\\'; To = '\\' },
@@ -65,7 +65,7 @@ Function Add-StepSummary {
6565
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_addgithubactionsstepsummary')]
6666
[OutputType([Void])]
6767
Param (
68-
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][AllowEmptyCollection()][AllowEmptyString()][AllowNull()][Alias('Content')][String[]]$Value,
68+
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][AllowEmptyCollection()][AllowEmptyString()][AllowNull()][Alias('Content')][Object[]]$Value,
6969
[Parameter(ValueFromPipelineByPropertyName = $True)][Switch]$NoNewLine
7070
)
7171
Process {
@@ -74,10 +74,7 @@ Function Add-StepSummary {
7474
Return
7575
}
7676
If ($Value.Count -gt 0) {
77-
Add-Content -LiteralPath $Env:GITHUB_STEP_SUMMARY -Value (
78-
$Value |
79-
Join-String -Separator "`n"
80-
) -Confirm:$False -NoNewline:($NoNewLine.IsPresent) -Encoding 'UTF8NoBOM'
77+
Add-Content -LiteralPath $Env:GITHUB_STEP_SUMMARY -Value $Value -Confirm:$False -NoNewline:($NoNewLine.IsPresent) -Encoding 'UTF8NoBOM'
8178
}
8279
}
8380
}
@@ -91,8 +88,6 @@ Add header for the step to display on the summary page of a run.
9188
Level of the header.
9289
.PARAMETER Header
9390
Title of the header.
94-
.PARAMETER NoEscape
95-
Whether to not escape the markdown characters that can cause issues.
9691
.OUTPUTS
9792
[Void]
9893
#>
@@ -101,10 +96,9 @@ Function Add-StepSummaryHeader {
10196
[OutputType([Void])]
10297
Param (
10398
[Parameter(Mandatory = $True, Position = 0)][ValidateRange(1, 6)][Byte]$Level,
104-
[Parameter(Mandatory = $True, Position = 1)][ValidatePattern('^.+$', ErrorMessage = 'Parameter `Header` must be in single line string!')][Alias('Title', 'Value')][String]$Header,
105-
[Alias('NoFormat', 'SkipEscape', 'SkipFormat')][Switch]$NoEscape
99+
[Parameter(Mandatory = $True, Position = 1)][ValidatePattern('^.+$', ErrorMessage = 'Parameter `Header` must be in single line string!')][Alias('Title', 'Value')][String]$Header
106100
)
107-
Add-StepSummary -Value "$('#' * $Level) $($NoEscape.IsPresent ? $Header : ([GitHubActionsStepSummary]::EscapeMarkdown($Header)))"
101+
Add-StepSummary -Value "$('#' * $Level) $Header"
108102
}
109103
<#
110104
.SYNOPSIS
@@ -134,7 +128,7 @@ Function Add-StepSummaryImage {
134128
Param (
135129
[Parameter(Mandatory = $True, Position = 0)][Alias('Url')][String]$Uri,
136130
[String]$Title,
137-
[Alias('AltText')][String]$AlternativeText,
131+
[Alias('Alt', 'AltText')][String]$AlternativeText,
138132
[ValidateRange(0, [Int32]::MaxValue)][Int32]$Width = -1,
139133
[ValidateRange(0, [Int32]::MaxValue)][Int32]$Height = -1,
140134
[Switch]$NoNewLine

hugoalh.GitHubActionsToolkit/module/tool-cache.psm1

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ Import-Module -Name (
99
.SYNOPSIS
1010
GitHub Actions - Expand Tool Cache Compressed File
1111
.DESCRIPTION
12-
Expand a compressed archive/file.
12+
Expand an archive or a compressed file.
1313
.PARAMETER File
14-
Path of the compressed archive/file.
14+
Path of the archive or the compressed file.
1515
.PARAMETER Destination
1616
Path for the expand destination.
1717
.PARAMETER Method
18-
Method to expand compressed archive/file; Define this parameter will enforce to use defined method.
18+
Method to expand the archive or the compressed file; Define this parameter will enforce to use the defined method.
1919
.PARAMETER 7zrPath
2020
Literal path of the 7zr application, for long path support (only when parameter `Method` is `7z`).
2121
22-
Most `.7z` archives do not have this problem, if `.7z` archive contains very long path, pass the path to 7zr which will gracefully handle long paths, by default 7zdec is used because it is a very small program and is bundled with the GitHub Actions NodeJS toolkit, however it does not support long paths, 7zr is the reduced command line interface, it is smaller than the full command line interface, and it does support long paths, at the time of this writing, it is freely available from the LZMA SDK that is available on the 7-Zip website, be sure to check the current license agreement, if 7zr is bundled with your action, then the path to 7zr can be pass to this function.
22+
Most of the `.7z` archives do not have this problem, if `.7z` archive contains very long path, pass the path to 7zr which will gracefully handle long paths, by default 7zdec is used because it is a very small program and is bundled with the GitHub Actions NodeJS toolkit, however it does not support long paths, 7zr is the reduced command line interface, it is smaller than the full command line interface, and it does support long paths, at the time of this writing, it is freely available from the LZMA SDK that is available on the 7-Zip website, be sure to check the current license agreement, if 7zr is bundled with your action, then the path to 7zr can be pass to this function.
2323
.PARAMETER Flag
2424
Flag to use for expand (only when parameter `Method` is `Tar` or `Xar`).
2525
.OUTPUTS
@@ -71,7 +71,7 @@ Function Expand-ToolCacheCompressedFile {
7171
$Argument.Destination = $Destination
7272
}
7373
If ($7zrPath.Length -gt 0) {
74-
$Argument['7zrPath'] = $7zrPath
74+
$Argument.('7zrPath') = $7zrPath
7575
}
7676
If ($Flag.Length -gt 0) {
7777
$Argument.Flag = $Flag
@@ -103,16 +103,16 @@ Function Find-ToolCache {
103103
[OutputType(([String], [String[]]))]
104104
Param (
105105
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][Alias('ToolName')][String]$Name,
106-
[Parameter(ValueFromPipelineByPropertyName = $True)][Alias('V', 'Ver')][String]$Version,
106+
[Parameter(ValueFromPipelineByPropertyName = $True)][Alias('V', 'Ver')][SemVer]$Version,
107107
[Parameter(ValueFromPipelineByPropertyName = $True)][Alias('Arch')][String]$Architecture
108108
)
109109
Process {
110110
[Hashtable]$Argument = @{
111111
Name = $Name
112112
}
113-
[Boolean]$IsFindAll = $Version.Length -eq 0
113+
[Boolean]$IsFindAll = $Version.ToString().Length -eq 0
114114
If (!$IsFindAll) {
115-
$Argument.Version = $Version
115+
$Argument.Version = $Version.ToString()
116116
}
117117
If ($Architecture.Length -gt 0) {
118118
$Argument.Architecture = $Architecture
@@ -185,14 +185,14 @@ Function Register-ToolCacheDirectory {
185185
Param (
186186
[Parameter(Mandatory = $True, Position = 0, ValueFromPipelineByPropertyName = $True)][Alias('SourceDirectory')][String]$Source,
187187
[Parameter(Mandatory = $True, Position = 1, ValueFromPipelineByPropertyName = $True)][Alias('ToolName')][String]$Name,
188-
[Parameter(Mandatory = $True, Position = 2, ValueFromPipelineByPropertyName = $True)][Alias('V', 'Ver')][String]$Version,
188+
[Parameter(Mandatory = $True, Position = 2, ValueFromPipelineByPropertyName = $True)][Alias('V', 'Ver')][SemVer]$Version,
189189
[Parameter(ValueFromPipelineByPropertyName = $True)][Alias('Arch')][String]$Architecture
190190
)
191191
Process {
192192
[Hashtable]$Argument = @{
193193
Source = $Source
194194
Name = $Name
195-
Version = $Version
195+
Version = $Version.ToString()
196196
}
197197
If ($Architecture.Length -gt 0) {
198198
$Argument.Architecture = $Architecture
@@ -226,15 +226,15 @@ Function Register-ToolCacheFile {
226226
[Parameter(Mandatory = $True, Position = 0, ValueFromPipelineByPropertyName = $True)][Alias('SourceFile')][String]$Source,
227227
[Parameter(Mandatory = $True, Position = 1, ValueFromPipelineByPropertyName = $True)][Alias('TargetFile')][String]$Target,
228228
[Parameter(Mandatory = $True, Position = 2, ValueFromPipelineByPropertyName = $True)][Alias('ToolName')][String]$Name,
229-
[Parameter(Mandatory = $True, Position = 3, ValueFromPipelineByPropertyName = $True)][Alias('V', 'Ver')][String]$Version,
229+
[Parameter(Mandatory = $True, Position = 3, ValueFromPipelineByPropertyName = $True)][Alias('V', 'Ver')][SemVer]$Version,
230230
[Parameter(ValueFromPipelineByPropertyName = $True)][Alias('Arch')][String]$Architecture
231231
)
232232
Process {
233233
[Hashtable]$Argument = @{
234234
Source = $Source
235235
Target = $Target
236236
Name = $Name
237-
Version = $Version
237+
Version = $Version.ToString()
238238
}
239239
If ($Architecture.Length -gt 0) {
240240
$Argument.Architecture = $Architecture

hugoalh.GitHubActionsToolkit/module/utility.psm1

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,16 @@ Get the debug status of the runner.
4545
.OUTPUTS
4646
[Boolean] Debug status.
4747
#>
48-
Function Get-IsDebug {
49-
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_getgithubactionsisdebug')]
48+
Function Get-DebugStatus {
49+
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_getgithubactionsdebugstatus')]
5050
[OutputType([Boolean])]
5151
Param ()
5252
Write-Output -InputObject (
5353
$Env:RUNNER_DEBUG -ieq '1' -or
5454
$Env:RUNNER_DEBUG -ieq 'true'
5555
)
5656
}
57+
Set-Alias -Name 'Get-IsDebug' -Value 'Get-DebugStatus' -Option 'ReadOnly' -Scope 'Local'
5758
<#
5859
.SYNOPSIS
5960
GitHub Actions - Get Webhook Event Payload
@@ -80,6 +81,7 @@ Function Get-WebhookEventPayload {
8081
Write-Output
8182
}
8283
Set-Alias -Name 'Get-Event' -Value 'Get-WebhookEventPayload' -Option 'ReadOnly' -Scope 'Local'
84+
Set-Alias -Name 'Get-EventPayload' -Value 'Get-WebhookEventPayload' -Option 'ReadOnly' -Scope 'Local'
8385
Set-Alias -Name 'Get-Payload' -Value 'Get-WebhookEventPayload' -Option 'ReadOnly' -Scope 'Local'
8486
Set-Alias -Name 'Get-WebhookEvent' -Value 'Get-WebhookEventPayload' -Option 'ReadOnly' -Scope 'Local'
8587
Set-Alias -Name 'Get-WebhookPayload' -Value 'Get-WebhookEventPayload' -Option 'ReadOnly' -Scope 'Local'
@@ -95,9 +97,9 @@ Function Get-WorkflowRunUri {
9597
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_getgithubactionsworkflowrunuri')]
9698
[OutputType([String])]
9799
Param ()
98-
ForEach ($EnvironmentPath In @('GITHUB_SERVER_URL', 'GITHUB_REPOSITORY', 'GITHUB_RUN_ID')) {
99-
If ([String]::IsNullOrEmpty((Get-Content -LiteralPath "Env:\$EnvironmentPath" -ErrorAction 'SilentlyContinue'))) {
100-
Write-Error -Message "Unable to get the GitHub Actions workflow run URI: Environment path ``$EnvironmentPath`` is not defined!" -Category 'ResourceUnavailable'
100+
ForEach ($Item In @('GITHUB_SERVER_URL', 'GITHUB_REPOSITORY', 'GITHUB_RUN_ID')) {
101+
If ([String]::IsNullOrEmpty((Get-Content -LiteralPath "Env:\$Item" -ErrorAction 'SilentlyContinue'))) {
102+
Write-Error -Message "Unable to get the GitHub Actions workflow run URI: Environment path ``$Item`` is not defined!" -Category 'ResourceUnavailable'
101103
Return
102104
}
103105
}
@@ -135,12 +137,12 @@ Function Test-Environment {
135137
[Switch]$ToolCache,
136138
[Alias('Require', 'Required')][Switch]$Mandatory,
137139
[Alias('RequiredMessage', 'RequireMessage')][String]$MandatoryMessage = 'This process requires to invoke inside the GitHub Actions environment!',
138-
[Switch]$StepSummary# Deprecated, keep as legacy.
140+
[Switch]$StepSummary# Deprecated.
139141
)
140142
If ($PSBoundParameters.ContainsKey('StepSummary')) {
141143
Write-Warning -Message 'Parameter `StepSummary` is deprecated and will remove in the future version!'
142144
}
143-
[Hashtable[]]$Conditions = @(
145+
[Hashtable[]]$Items = @(
144146
@{ NeedTest = $True; Name = 'CI'; ExpectValue = 'true' },
145147
@{ NeedTest = $True; Name = 'GITHUB_ACTION'; },
146148
@{ NeedTest = $True; Name = 'GITHUB_ACTIONS'; ExpectValue = 'true' },
@@ -183,18 +185,18 @@ Function Test-Environment {
183185
@{ NeedTest = $OpenIdConnect.IsPresent; Name = 'ACTIONS_ID_TOKEN_REQUEST_URL'; }
184186
)
185187
[Boolean]$Failed = $False
186-
ForEach ($Condition In $Conditions) {
187-
If ($Condition.NeedTest) {
188-
If ($Null -ieq $Condition.ExpectValue) {
189-
If ([String]::IsNullOrEmpty((Get-Content -LiteralPath "Env:\$($Condition.Name)" -ErrorAction 'SilentlyContinue'))) {
188+
ForEach ($Item In $Items) {
189+
If ($Item.NeedTest) {
190+
If ($Null -ieq $Item.ExpectValue) {
191+
If ([String]::IsNullOrEmpty((Get-Content -LiteralPath "Env:\$($Item.Name)" -ErrorAction 'SilentlyContinue'))) {
190192
$Failed = $True
191-
Write-Warning -Message "Unable to get the GitHub Actions resources: Environment path ``$($Condition.Name)`` is not defined!"
193+
Write-Warning -Message "Unable to get the GitHub Actions resources: Environment path ``$($Item.Name)`` is not defined!"
192194
}
193195
}
194196
Else {
195-
If ((Get-Content -LiteralPath "Env:\$($Condition.Name)" -ErrorAction 'SilentlyContinue') -ine $Condition.ExpectValue) {
197+
If ((Get-Content -LiteralPath "Env:\$($Item.Name)" -ErrorAction 'SilentlyContinue') -ine $Item.ExpectValue) {
196198
$Failed = $True
197-
Write-Warning -Message "Unable to get the GitHub Actions resources: Environment path ``$($Condition.Name)`` is not defined or not equal to expect value!"
199+
Write-Warning -Message "Unable to get the GitHub Actions resources: Environment path ``$($Item.Name)`` is not defined or not equal to expect value!"
198200
}
199201
}
200202
}
@@ -212,14 +214,16 @@ Function Test-Environment {
212214
}
213215
Export-ModuleMember -Function @(
214216
'Add-SecretMask',
215-
'Get-IsDebug',
217+
'Get-DebugStatus',
216218
'Get-WebhookEventPayload',
217219
'Get-WorkflowRunUri',
218220
'Test-Environment'
219221
) -Alias @(
220222
'Add-Mask',
221223
'Add-Secret',
222224
'Get-Event',
225+
'Get-EventPayload',
226+
'Get-IsDebug',
223227
'Get-Payload',
224228
'Get-WebhookEvent',
225229
'Get-WebhookPayload',

0 commit comments

Comments
 (0)