Create dynamic list of runner labels in GitHub Actions

I have used the GitHub Action feature which allows to dynamically provide runner label based on matrix attribute: Workflow syntax for GitHub Actions - GitHub Docs.
In my case I need to specify more than one label and I don’t know how to do it.
I have tried two different approaches and none of them worked for me:

  1. runs-on: [ self-hosted, my_project, ${{ matrix.os }} ] - this gives me “workflow is invalid: You have an error in your yaml syntax” error.
  2. runs-on: ${{ matrix.os == 'linux' && '[ self-hosted, my_project, linux ]' || '[ self-hosted, my_project, windows ]' }} - this treats entire [ self-hosted, my_project, linux ] as a single label instead of array of labels.

You probably want to use fromJson: