Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 2

What is the correct if condition syntax for checking matrix.os version?

Solved! Go to Solution.

Hi,

 

I previously used travis with a build matrix and could check in if condtions for the os-version/type, however in GithubActions I couldn't figure out what the correct syntax is:

I tested both with and without expression braces:

 - if:  matrix.os  == 'ubuntu-latest'
      run: |
        ionic cordova platform add android
        ionic cordova build android
 
and something like:
    - if: ${{ matrix.os == 'macOS-10.14'}}
run: | ionic cordova platform add ios ionic cordova build ios
Both give me errors:
- Your workflow file was invalid: .github/workflows/main.yml (Line: 33, Col: 11): Unrecognized named-value: 'matrix'. Located at position 1 within expression: matrix.os == 'macOS-10.14'
 
1 Reply
Solution
Copilot Lvl 3
Message 2 of 2

Re: What is the correct if condition syntax for checking matrix.os version?

I figured it out and now it works:

 

- if: matrix.os == 'macOS-10.14'
      run: |
        ionic cordova platform add ios
        ionic cordova build ios

 - if: matrix.os == 'ubuntu-latest'
      run: |
        ionic cordova platform add android
        ionic cordova build android