Github action binaries execution colors

Viewed 164

When using github action and shell: bash parameter, I don't get the color output from the command I am executing.

Example:

  • Using binary kube-score

Here is my script in github action:

name: 'Kube-score'
description: 'Kubernetes object analysis with recommendations for improved reliability and security.'
author: 'ixxeL'
inputs:
  format:
    description: 'Format result. [human,ci,json]'
    required: false
    default: 'human'
  kube-version:
    description: 'Setting the kubernetes-version will affect the checks ran against the manifests.'
    required: false
    default: 'v1.18'
  working-dir:
    description: 'file to scan'
    required: false
    default: './*.yaml'
runs:
  using: "composite"
  steps:
    - id: kube-score
      shell: bash
      run: |
        kube-score score --output-format=${{ inputs.format }} \
                         --kubernetes-version=${{ inputs.kube-version }} \
                         ${{ inputs.working-dir }}

And the result when code is executed :

Output result in github action

when it should look like this (on my terminal):

Output result in terminal

Any idea on how to force colors in my output ?

1 Answers

As mentioned in actions/runner issue 241, this could be a TTY problem: no TTY detected, no color generated by the zegl/kube-score command.

Try and force one (a TTY) with:

shell: 'script --return --quiet --command "bash {0}"'
run: |
 <command requiring TTY>
Related