name: "Setup Node"
description: |
  Sets up the node environment for tests, builds, etc.
inputs:
  directory:
    description: |
      The directory to run the setup in.
    required: false
    default: "site"
runs:
  using: "composite"
  steps:
    - name: Install pnpm
      uses: pnpm/action-setup@v3
      with:
        version: 9.6
    - name: Setup Node
      uses: actions/setup-node@v4.0.3
      with:
        node-version: 20.16.0
        # See https://github.com/actions/setup-node#caching-global-packages-data
        cache: "pnpm"
        cache-dependency-path: ${{ inputs.directory }}/pnpm-lock.yaml
    - name: Install root node_modules
      shell: bash
      run: ./scripts/pnpm_install.sh

    - name: Install node_modules
      shell: bash
      run: ../scripts/pnpm_install.sh
      working-directory: ${{ inputs.directory }}
