Use output array in runs-on

In the first job, I generate an array with all machines and I am trying to use it in the second job

Full workflow

name: build-kotlin

on:
  workflow_call:
    inputs:
      machines:
        description: 'Virtual environments, default is `ubuntu-latest`'
        default: 'ubuntu-latest'
        required: false
        type: string

jobs:
  select-machines:
    runs-on: 'ubuntu-latest'

    outputs:
      matrix: ${{ steps.machines.outputs.matrix }}

    steps:
      - name: Setup machines matrix
        id: machines
        run: |
          IFS=', ' read -r -a machines <<< ${{ inputs.machines }}
          echo "::set-output name=matrix::${machines}"

  build:
    needs: select-machines

    strategy:
      fail-fast: false
      matrix:
        os: ${{ needs.select-machines.outputs.matrix }}

    runs-on: '${{ matrix.os }}'

But I got those errors:

  • using only ubuntu-latest

Maybe I am generating a wrong array or something so? I don’t know bash a lot.