I am glad that the GH team implemented jobs.<jobs_id>.outputs but I found a scenario where this feature does not work as expected.
jobs:
one:
runs-on: ${{ matrix.os }}
outputs:
myvar: ${{ steps.step1.outputs.myvar }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- id: step1
run: echo "::set-output name=myvar::${{ matrix.os }}"
two:
runs-on: ubuntu-latest
needs: one
steps:
- run: echo '${{ needs.one.outputs.myvar }}'
- run: echo '${{ toJson(needs.one.outputs.myvar) }}'
- run: echo '${{ toJson(needs.one.outputs) }}'
The value of myvar
is determined by the last job run, while it should be the accumulated value of all jobs in the matrix. In other words the output of a matrix job should be an array of values, not a string, one value for each execution. In the example [ubuntu-latest, windows-latest]
or [windows-latest, ubuntu-latest]
.