Table of Contents
- A Straightforward Workflow
- Why Use a Matrix Strategy?
- Converting to a Matrix Workflow
- Handling Failures in a Matrix
- Further Reading
1. A Straightforward Workflow
Here’s a basic GitHub Actions workflow that runs two independent jobs—one on Ubuntu, one on Windows—to echo Docker info and launch thehello-world container:



hello-world output confirms success:
2. Why Use a Matrix Strategy?
Maintaining separate jobs for each OS, language version, or container image can quickly become repetitive and error-prone.Matrix strategy automatically runs all defined combinations in parallel, speeding up CI/CD feedback.
3. Converting to a Matrix Workflow
Let’s test two Docker images—hello-world and alpine—across three platforms: ubuntu-latest, ubuntu-20.04, and windows-latest. We’ll leverage the matrix variables in both runs-on and our Docker commands:


4. Handling Failures in a Matrix
By default, any failing combination halts the workflow and marks it as failed. For example,alpine isn’t compatible with Windows, so that job errors out:

A single matrix failure by default stops all running jobs. Use
strategy.fail-fast: false or exclude incompatible combinations with matrix.exclude.exclude and conditional execution.
5. Further Reading
- GitHub Actions: Matrix strategy
- Docker Hub – Alpine Official Image
- GitHub Actions Workflow syntax for GitHub Actions