name: Setup and Install
description: Sets up Node.js and installs dependencies

runs:
  using: "composite"
  steps:
    - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
      with:
        node-version: 24<% if (packageManager !== 'yarn') { %>
        cache: <%= packageManager %><% } %>
    - name: Enable Corepack
      shell: bash
      run: corepack enable<% if (packageManager === 'yarn') { %>
    - name: Get yarn cache directory path
      shell: bash
      id: yarn-cache-dir-path
      run: echo "dir=$(<% if (yarn2) { %>yarn config get cacheFolder<% } else { %>yarn cache dir<% } %>)" >> $GITHUB_OUTPUT
    - name: Cache dependencies
      uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
      with:
        path: |
          ${{ steps.yarn-cache-dir-path.outputs.dir }}
          <% if (yarn2) { %>.yarn/unplugged
          .pnp.cjs
          .pnp.loader.mjs<% } %>
        key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
        restore-keys: |
          ${{ runner.os }}-yarn
          ${{ runner.os }}<% } %>
    - name: Install<% if (npmRegistry) { %>
      env:
        COREPACK_NPM_REGISTRY: <%= npmRegistry %>
        COREPACK_INTEGRITY_KEYS: ""<% } %>
      shell: bash
      run: <%= setupCommand %>
