forked from StartAutomating/PSDevOps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHide-GitHubOutput.ps1
37 lines (36 loc) · 1.14 KB
/
Hide-GitHubOutput.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function Hide-GitHubOutput
{
<#
.Synopsis
Masks output
.Description
Prevents a message from being printed in a GitHub Workflow log.
.Example
Hide-GitHubOutput 'IsItSecret?'
'IsItSecret?' | Out-Host
.Link
Write-GitHubOutput
.Link
https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions
#>
[OutputType([string])]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "",
Justification="Directly outputs in certain scenarios")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("Test-ForUnusableFunction", "",
Justification="Directly outputs in certain scenarios")]
param(
[Parameter(Mandatory,Position=0,ValueFromPipelineByPropertyName)]
[string]
$Message
)
process {
#region Write or output the GitHub add-mask command.
$out = "::add-mask::$Message"
if ($env:GITHUB_WORKFLOW -and $DebugPreference -eq 'SilentlyContinue') {
Write-Host $out
} else {
$out
}
#endregion Write or output the GitHub add-mask command.
}
}