Reputation: 13
I'm new to GitHub Actions and was trying out the matrix build following an online course as follows:
name: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [10.x, 12.x]
os: [ubuntu-latest, windows-2016]
steps:
- uses: actions/checkout@v2
- name: npm install and build webpack
run: |
npm install
npm run build
In that course, it is runs-on: ubuntu-latest
, but still the matrix takes effect.
So does runs-on get overridden if the matrix is defined even if I don't explicitly say runs-on: ${{ matrix.os }}
?
Thanks
Upvotes: 0
Views: 2948
Reputation: 23210
Here, you defined the strategy with the matrix, but you're not using it anywhere, so those node-version
and os
values won't be taken into consideration.
Therefore, it won't override the runner because you didn't specify that the os
field from the matrix should be used as the job runs-on
field.
You need to specify the ${{ matrix.os }}
somewhere first if you want to use it. So it won't override your runner here, you have to specify runs-on: ${{ matrix.os }}
As you implemented your workflow, the same job will run 4 times as it will detect the strategy
(twice for the different node-version
; and twice for the different os
) but with the same step and job configurations, as nothing is using the matrix values there.
Upvotes: 3