Can a matrix job produce outputs for downstream jobs?
AdvancedConceptJobs, Steps, Matrix & Concurrency
Answer
Job outputs from a matrix are not merged; all legs write the same output name and the last one to finish wins, which is nondeterministic. Patterns that work:
- Output names are static, so legs cannot write
digest-${{ matrix.arch }}as separate outputs. Instead each leg uploads an artifact named per leg (digest-amd64,digest-arm64), and a fan-in job downloads them withpattern: digest-*andmerge-multiple: true. - Or write results to a store (S3, a check run, a PR comment) keyed by the matrix value.
More on Jobs, Steps, Matrix & Concurrency
How does `needs` work, and what happens to a job whose dependency failed or was skipped?BeginnerWhat is the implicit `success()` in a job `if`, and why is `always()` usually the wrong fix?IntermediateWhat values can `needs.<job>.result` take?BeginnerHow does a matrix expand, and how are job names generated?BeginnerHow do `include` and `exclude` work in a matrix?IntermediateWhat do `fail-fast` and `max-parallel` do?Beginner