Skip to content

Commit caf95d6

Browse files
committed
Improve Add-GHActionsSecretMask with Smart
1 parent 0d4084b commit caf95d6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

hugoalh.GitHubActionsToolkit/hugoalh.GitHubActionsToolkit.psm1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,28 @@ GitHub Actions - Add Secret Mask
216216
Make a secret will get masked from the log.
217217
.PARAMETER Value
218218
The secret.
219+
.PARAMETER Smart
220+
Use improved method to well make a secret will get masked from the log.
219221
.OUTPUTS
220222
Void
221223
#>
222224
function Add-GHActionsSecretMask {
223225
[CmdletBinding()][OutputType([void])]
224226
param(
225-
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)][Alias('Key', 'Token')][string]$Value
227+
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)][Alias('Key', 'Token')][string]$Value,
228+
[switch]$Smart
226229
)
227230
begin {}
228231
process {
229232
Write-GHActionsCommand -Command 'add-mask' -Message $Value
233+
if ($Smart) {
234+
[string[]]$Bin = $Value -split "[\n\r\s\t]+"
235+
$Bin | ForEach-Object -Process {
236+
if (($_ -ne $Value) -and ($_.Length -ge 2)) {
237+
Write-GHActionsCommand -Command 'add-mask' -Message $_
238+
}
239+
}
240+
}
230241
}
231242
end {}
232243
}

0 commit comments

Comments
 (0)