Skip to content

How to share matrix between jobs #26284

Discussion options

You must be logged in to vote

I think I figured out a way to do this: I place the configuration in a separate file, matrix.json:

[
  { "go": "1.13", "commit": "v1.0.0" },
  { "go": "1.14", "commit": "v1.2.0" },
]

The config uses a separate matrix step to read this JSON file from disk:

matrix:
  runs-on: ubuntu-latest
  outputs:
    matrix: ${{ steps.set-matrix.outputs.matrix }}
  steps:
    - uses: actions/checkout@v2
    - id: set-matrix
      run: |
        TASKS=$(echo $(cat .github/workflows/matrix.json) | sed 's/ //g' )
        echo "::set-output name=matrix::$TASKS"
builder:
  needs: [ matrix ]
  strategy:
    matrix:
      cfg: ${{ fromJson(needs.matrix.outputs.matrix) }}
  steps:
    // upload binary named "b…

Replies: 11 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment