Github Action use matrices with reuse-able workflow

Viewed 1662

I've been rooting through the Github Action documentation around re-useable workflows and am attempting to piece together a chain of matrices.

My pseudo workflow looks something like the following steps.

  • Job 1: Figure out files changed under a path & output them as json
  • Job 2: Iterate the file list as a matrix and invoke another workflow.
  • Job 3 (in other workflow): Simply use another matrix definition in conjunction with the single input value to perform a set of steps.

It would seem a relatively simple objective. Yet it looks like workflow re-useable calls do not support strategy. Correct me if I'm wrong?

1 Answers

It appears matrix (strategy) can't be used with reusable actions, at least right now. See GH Actions docs.

Given that reusable actions went GA literally yesterday, I expect this might eventually change. Notice the announcement shows an example with a matrix... And the replacement conveniently leaves out what's being called.

As far as I understand it, the limitation can be rephrased as "you can't write a C style for loop" - you can't have the caller workflow use strategy on a job that is a reusable action call. However you can reverse the relationship: Move strategy into the reused workflow (callee). Then, you can also pass in the matrix in inputs as a JSON encoded in a string. See the discussion about this workaround.

That's certainly not good enough for me, but judge yourself.

Related