Condition Syntax Berdasarkan OS Yang Dijalankan Saat Ini

if: matrix.os == 'ubuntu-latest'

if: matrix.os == 'windows-latest'

if: matrix.os == 'macOS-latest'

Condition Syntax Berdasarkan Konteks OS Yang Dijalankan Saat Ini

if: runner.os == 'Linux'

if: runner.os == 'Windows'

if: runner.os == 'macOS'

Contoh Kondisi Job Menggunakan variable RUNNER_OS

- name:  Install
  run:   |
         if [ "$RUNNER_OS" == "Linux" ]; then
              apt install important_linux_software
         elif [ "$RUNNER_OS" == "Windows" ]; then
              choco install important_windows_software
         else
              echo "$RUNNER_OS not supported"
              exit 1
         fi
  shell: bash

Source

Contoh Lengkap GitHub Workflow Job Berdasarkan OS

runs-on: ${{ matrix.os }}
strategy:
    matrix:
        os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
    - name: Setup Ubuntu
      run : echo "iam running on LINUX"
      if: runner.os == 'Linux'