name: Reusable — pnpm Workspace

on:
  workflow_call:
    inputs:
      node-version:
        type: string
        default: '20'
      pnpm-version:
        type: string
        default: '10'
      command:
        type: string
        required: true
      timeout-minutes:
        type: number
        default: 10

jobs:
  run:
    name: Run
    runs-on: ubuntu-latest
    timeout-minutes: ${{ inputs.timeout-minutes }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup pnpm
        uses: pnpm/action-setup@v4
        with:
          version: ${{ inputs.pnpm-version }}

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: ${{ inputs.node-version }}
          cache: pnpm

      - name: Install dependencies
        run: pnpm install --frozen-lockfile

      - name: Run command
        run: ${{ inputs.command }}
