As a DevOps engineer, you are developing workflows to build an application. You have a requirement to create the build targeting multiple node versions. Which code block should you use to define the workflow?
The correct GitHub Actions syntax for running a job across multiple Node.js versions is strategy.matrix. The matrix values are referenced at runtime through the matrix context, so node-version: ${{ matrix.node-ver }} is correct. Option A defines the matrix correctly but references it incorrectly through strategy.node-ver; matrix values are not accessed through the strategy context. Option C uses matrix-strategy, which is not a valid GitHub Actions workflow key. Option D reverses the structure by putting strategy under matrix, which is invalid. This question tests matrix strategy syntax, dynamic job configuration, and using matrix values as inputs to actions such as actions/setup-node. GitHub defines jobs.<job_id>.strategy.matrix as the proper matrix mechanism.
Currently there are no comments in this discussion, be the first to comment!