action-setup icon indicating copy to clipboard operation
action-setup copied to clipboard

NPM package in subdirectory of repo does not work

Open eighty4 opened this issue 1 year ago • 1 comments

Here is a repo where the NPM package is in a subdir (in this case apex): https://github.com/eighty4/eighty4.tech

When trying pnpm/action-setup I've run through variations of the config without any way of getting past the action failing looking for the pnpm lockfile at the repository root. Here are variations I've tried.

As a user I would expect just setting package_json_file path would work:

      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
        with:
          package_json_file: apex/package.json

I tried changing the cwd of run_install:

      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
        with:
          package_json_file: apex/package.json
          run_install: |
            - cwd: apex
              args: []

Even with run_install: false it still fails on the missing repository root pnpm lock file:

      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
        with:
          package_json_file: apex/package.json
          run_install: false

Am I overlooking a configuration for this project structure to work with pnpm/action-setup?

eighty4 avatar Jan 09 '25 18:01 eighty4

Actually, setting run_install to false and specifying package_json_file worked for me

env: 
  BASE_DIR: my-subdirectory

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install pnpm
        uses: pnpm/action-setup@v2
        with:
          run_install: false
          package_json_file: '${{ env.BASE_DIR }}/package.json'
        
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '22'
          cache: 'pnpm'
          cache-dependency-path: '${{ env.BASE_DIR }}/pnpm-lock.yaml'
          
      - name: Install dependencies
        working-directory: ${{ env.BASE_DIR }}
        run: pnpm install --frozen-lockfile
        
      - name: Build admin frontend
        working-directory: ${{ env.BASE_DIR }}
        run: pnpm run build

jesuissuyaa avatar Jun 02 '25 05:06 jesuissuyaa