What is the correct if condition syntax for checking matrix.os version? #25554
-
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:
and something like:
Both give me errors:
|
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 1 reply
-
I figured it out and now it works:
|
Beta Was this translation helpful? Give feedback.
-
Does’t work. I get “You have an error in your yaml syntax on line 30” with this: - name: Install Depencies unless Windows - if: matrix.os != ‘windows-latest’ run: cpanm -iqn BSD::Resource Of course, it’s not helpful that Github doesn’t tell you what the syntax error is, or the place in the line that the error occured. |
Beta Was this translation helpful? Give feedback.
-
This works fine for me. Maybe your indentation is wrong? |
Beta Was this translation helpful? Give feedback.
-
I checked and double checked the indentation. Looks right to me. And there are no tabs either. |
Beta Was this translation helpful? Give feedback.
-
Looking more, the indentation isn’t clear to me. In your answer the ‘run’ is under the ‘if’; whereas in the ‘solved’ response it’s indented by four spaces. I indented by two. |
Beta Was this translation helpful? Give feedback.
-
That was it. It wants no indend, the “solved” solution is wrong. |
Beta Was this translation helpful? Give feedback.
-
I think it could be a copy paste problem with the forum here which killed the right indentations |
Beta Was this translation helpful? Give feedback.
-
Having separate names makes it work fine - name: Setup wine Ubuntu
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt install wine
- name: Setup wine macOS
if: matrix.os =='macos-latest'
run: |
brew install wine-stable --cask This is way better than the shell way, as windows breaks when it tries this command: if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt install wine
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install wine-stable --cask
fi |
Beta Was this translation helpful? Give feedback.
I figured it out and now it works:
if: matrix.os == 'ubuntu-latest'
run: |
ionic cordova platform add android
ionic cordova build android