I have started working with nektos/act repository to run my Github Actions locally and what I want to do is to display the original color logs only for the steps in my workflow at .github/workflows/lint.yml
. Since the --verbose
flag does not allow me to filter these logs, I have been using grep
and it works as expected with the following command.
act push --secret-file .secrets --rm | grep -ivw -e "🐳" -e "🚀"
and the output is:
But, without grep (just act command), the lines that start with:
[clang-format-lint/cpp-linters]
are colored:
Does anyone know how to keep the act format, but filter for steps only with the original color (yellow/blue)?
Solution:
unbuffer act push --secret-file .secrets --rm | grep -Ev "🐳|🚀"
The reason this happens is that programs usually only print terminal control sequences (colours) if the output file is a terminal device. Control sequences usually aren't printed if output is piped or redirected to a regular file.
If the command doesn't have an option to force colours (like --color=always
or similar), you can use the unbuffer
program from the expect
package, to make the program behave as if printing to a terminal.
unbuffer act ... | grep
Be aware that the output will contain control sequence strings, which may interfere with text filtering (using something like grep).