Skip to content

CICD-220 · Conditional matrix generation ​

Encyclopedia · Advanced workflow orchestration · All snippets

Previous · CICD-219 · Next · CICD-221

1. Where it fits ​

  • Placement .github/workflows/matrix.yml consumer job keys.
  • Prerequisites authenticated GitHub CLI, approved target repositories, or Actions runner for YAML entries.
  • Platforms github-actions.

2. Copy the snippet ​

yaml
needs: plan
if: needs.plan.outputs.targets != '[]'
strategy:
  matrix:
    service: ${{ fromJSON(needs.plan.outputs.targets) }}

3. How it works ​

The pre-matrix job condition checks the raw planner string before evaluating the strategy. Publishing a valid empty array makes the intended skip explicit.

4. Verify the result ​

Combine with CICD-219. An empty array skips the consumer before matrix expansion.

Validation syntax-validated (YAML parse). Status definitions.