Question about Better logs experience with GitHub Actions


I’m not sure to understand how to use ::set-env
Following the initial example from

      - name: Set selected color
        run: echo '::set-env name=SELECTED_COLOR::green'
      - name: Get color
        run: echo 'The selected color is' $SELECTED_COLOR

What I actually get in the console is:

I would have expected “Test Color” to be green…
What did I miss?

Where to find the example that generates this example:

as I guess I’m missing something obvious here :slight_smile:


The example I assume you’re referencing is only about setting an environment variable (which works, as shown by the “Get color” step), and has nothing to do with the text color.

You can use ANSI escape codes to get output in color, for example:

      - name: Test color output
        run: |
          print('\u001b[31mHello Red\u001b[0m')
          print('\u001b[32mHello Green\u001b[0m')
        shell: python3 {0}

Ok thanks.

I initially used the ANSI escape sequence, but I just forgot to specify -e for the echo commands, and it failed :slight_smile:
I then tried to use the env. var. syntax as I thought the SELECTED_COLOR had a special meaning for the runner. Me bad.

Thanks for your help, it now works.

1 Like