Github Actions Output Text Color

Viewed 3729

I have this GitHub action that runs my PowerShell test scripts. The test scripts outputs "[ERROR]" on an error and "[WARNING]" on a warning. Screenshot of colored GitHub Actions log I am wondering if there is any documentation on other keywords that are highlighted. The GitHub actions are running on 'windows-latest' in a pwsh/PowerShell shell.

1 Answers

The colors are not the result of GitHub Action itself, but of the testing framework used.

See for instance microsoft/vstest issue 2370 "Support Colorized Output in GitHub Actions"

xUnit.net does not attempt any colorization here. Our messages are passed to the VSTest API with just text and a level. All colorization in dotnet test is owned by VSTest.

What you see in a GitHub Action is the result of the tool used by that Action.

As mentioned in "A better logs experience with GitHub Actions" in Sept. 2020:

We want to be more mindful about color usage, which means we also need to acknowledge that people build their own scripts, commands, and tools to output useful information.

That’s why we are increasing the color support, including:

  • ANSI colors
  • 8-bit colors
  • 24-bit colors

This enables richer content and better integration when rendering information coming from third-party sources.

https://github.blog/wp-content/uploads/2020/09/color.png?resize=1024%2C699?w=1024

Related