Skip to content
Advertisement

How to propagate colors from bash script to CI (GitHub Actions, Travis, Gitlab…)?

I’m using GitHub Actions in CI. When I run commands directly in YAML recipe:

- run: composer install --ansi

the output is colored:

enter image description here


But then when I run the same command inside a bash script:

- run: sh composer-install.sh
# composer-install.sh

composer install --ansi

It’s without colors:

enter image description here


How can I propagate the colors through bash script to the CI output?

Advertisement

Answer

To enable colors, include this line in the bash script file:

export TERM=xterm-color

Cherry pick of @KenJackson comment.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement