name: 'Install Dependencies'
description: 'Installs yarn depdencies using cache when available'
runs:
  using: "composite"
  steps:
  - name: Get yarn cache directory path
    shell: bash
    id: yarn-cache-dir-path
    run: echo "dir=$(node src/electron/script/yarn.js config get cacheFolder)" >> $GITHUB_OUTPUT
  - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
    id: yarn-cache
    with:
      path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
      key: ${{ runner.os }}-yarn-${{ hashFiles('src/electron/yarn.lock') }}
      restore-keys: |
        ${{ runner.os }}-yarn-
  - name: Install Dependencies
    shell: bash
    run: |
      cd src/electron
      if [ "$TARGET_ARCH" = "x86" ]; then
        export npm_config_arch="ia32"
      fi
      # if running on linux arm skip yarn Builds
      ARCH=$(uname -m)
      if [ "$ARCH" = "armv7l" ]; then
        echo "Skipping yarn build on linux arm"
        node script/yarn.js install --immutable --mode=skip-build
      else
        node script/yarn.js install --immutable
      fi
