You want to run CI on macOS and Windows only for the release branch.
BeginnerScenarioGitHub Actions
Answer
Situation read → Costly runners for narrow use.
What I'd do →
- Use
runs-on: ${{ matrix.os }}withos: [ubuntu-latest, macos-latest, windows-latest]. - Gate expensive OSes:
includethem only whenstartsWith(github.ref, 'refs/heads/release/')via a dynamic matrix.
Why → macOS minutes cost several times more than Linux, so use them where they add value.
Interview tip → Linux for fast feedback, others for compatibility confidence.
More on GitHub Actions
What are workflows, jobs, steps and actions in GitHub Actions?BeginnerWhat events can trigger a workflow?BeginnerWhat is the difference between `pull_request` and `pull_request_target`?AdvancedWhat is a runner, and how do GitHub-hosted and self-hosted runners differ?BeginnerHow do you pass data between steps and between jobs?IntermediateHow does a build matrix work?Intermediate