Setting variables based OS architecture

Am trying to set variable architecture: x86 for setup-python if the matrix.config.os.arch == ‘ia32’ But I get an syntax error. What is correct way to set variables here?

 strategy:
      matrix:
        config:
          - { os: macos-latest, arch: x64, name: macos-latest }
          - { os: ubuntu-latest, arch: x64, name: ubuntu-latest }
          - { os: windows-latest, arch: x64, name: windows-latest }
          - { os: windows-latest, arch: ia32, name: windows-latest-32 }

    steps:
      - uses: actions/checkout@v1
      - name: Set up Python 3.8
        uses: actions/setup-python@v1
        with:
          python-version: 3.8
          if: ${{ matrix.config.os.arch == 'ia32'}} 
          architecture: x86 

@arky,

According to the configurations of the matrix in your workflow, the ‘os’ and the ‘arch’ are the same level options in the matrix. The ‘arch’ is not a child option of the ‘os’.

So, if you want to access the value of the ‘arch’ option, the correct expression syntax should be ‘matrix.config.arch’, not ‘matrix.config.os.arch’.

Similarly, using ‘matrix.config.os’ to access the value of the ‘os’ option, and ‘matrix.config.name’ to access the ‘name’.
Below is an example as reference:

@brightran Thanks again! I missed that. Looks like I am hitting multiple errors here. Firstly I can’t use if here. Wonder if there is shorthand to return ‘x86’ string if ‘matrix.config.arch == ia32’ is true.

architecture: {{ if: true return string }}

The syntax error


##[warning]Unexpected input(s) 'if', valid inputs are ['python-version', 'architecture']
Run actions/setup-python@v1
  with:
    python-version: 3.8
    if: false
    architecture: x86
##[error]Version 3.8 with arch x86 not found
Available versions:

Also python-setup doesn’t seem to have ‘x86’ architecture.

Resolved. Thanks for your help @brightran!

  matrix:
        config:
          - { os: macos-latest, arch: x64, python-arch: x64, name: macos-latest }
          - { os: ubuntu-latest, arch: x64, python-arch: x64, name: ubuntu-latest }
          - { os: windows-latest, arch: x64, python-arch: x64, name: windows-latest }
          - { os: windows-latest, arch: ia32, python-arch: x86, name: windows-latest-32 }

    steps:
      - uses: actions/checkout@v1
      - name: Set up Python 3.8
        uses: actions/setup-python@v1
        with:
          python-version: '3.8'
          architecture: ${{ matrix.config.python-arch }}
      ```