Skip to content

Write-GitHubLog

SYNOPSIS

Write a colored message in GitHub Actions or locally

SYNTAX

Write-GitHubLog [-Message] <String> [-ForegroundColor <ConsoleColor>] [-BackgroundColor <ConsoleColor>]
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Write a colored message in GitHub Actions or locally with ANSI color support. When running in GitHub Actions, uses ANSI color codes for text formatting. When not running in GitHub Actions, uses standard Write-Host.

EXAMPLES

EXAMPLE 1

Write-GitHubLog -Message 'Hello, World!'

Writes 'Hello, World!' to the log.

EXAMPLE 2

Write-GitHubLog -Message 'Error occurred!' -ForegroundColor Red

Writes 'Error occurred!' in red text.

EXAMPLE 3

Write-GitHubLog -Message 'Success!' -ForegroundColor Green -BackgroundColor Black

Writes 'Success!' in green text on a black background.

PARAMETERS

-Message

The message to display

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-ForegroundColor

Foreground color for the message

Type: ConsoleColor
Parameter Sets: (All)
Aliases:
Accepted values: Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-BackgroundColor

Background color for the message

Type: ConsoleColor
Parameter Sets: (All)
Aliases:
Accepted values: Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Void

NOTES

Uses PowerShell's $PSStyle for ANSI color rendering when supported.

https://psmodule.io/GitHub/Functions/Commands/Write-GitHubLog