diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8eb62c8..31cfaa0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,4 +10,5 @@ jobs: - uses: actions/checkout@v3 - uses: ./ with: + cwd: "test" install-ignore-scripts: true diff --git a/.gitignore b/.gitignore index 3c3629e..adceed6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +test/node_modules diff --git a/README.md b/README.md index c530e3a..005bc3a 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,21 @@ jobs: - name: setup node and pnpm uses: dafnik/setup-node-pnpm@v1 - # with: - # pnpm: 8 - # node: 18 - # install: false + with: + # PNPM version to install + pnpm: 8 + + # Node version to install + node: 18 + + # Changes pnpm-lock.yaml lookup location and the work directory of "pnpm install" if enabled + cwd: "." + + # Runs "pnpm install" in working directory + install: false + + # Runs "pnpm install --ingore-scripts" in working directory + # Enable "install" or "install-ignore-scripts" only once # install-ignore-scripts: false ``` diff --git a/action.yml b/action.yml index 6202cb6..da43d39 100644 --- a/action.yml +++ b/action.yml @@ -7,21 +7,29 @@ branding: inputs: pnpm: - description: 'PNPM version' + description: "PNPM version" required: false default: 8 node: description: "Node version" required: false default: 18 + cwd: + description: "Work directory" + required: false + default: "." + cache-dependency-path: + description: "Path to pnpm-lock.yaml" + required: false + default: "pnpm-lock.yaml" install: description: "Runs pnpm install" required: false - default: 'false' + default: "false" install-ignore-scripts: description: "Runs pnpm install --ignore-scripts" required: false - default: 'false' + default: "false" runs: using: "composite" @@ -35,28 +43,19 @@ runs: uses: actions/setup-node@v3 with: node-version: ${{ inputs.node }} - cache: 'pnpm' - - - name: get pnpm store directory - id: pnpm-dir - shell: bash - run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v3 - id: pnpm-cache - name: setup pnpm cache - with: - path: ${{ steps.pnpm-dir.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + cache: "pnpm" + cache-dependency-path: "${{ inputs.cwd }}/pnpm-lock.yaml" - name: Run pnpm install if: "${{ inputs.install == 'true' }}" shell: bash - run: pnpm install --frozen-lockfile + run: | + cd ${{ inputs.cwd }} + pnpm install --frozen-lockfile - name: Run pnpm install --ignore-scripts if: "${{ inputs.install-ignore-scripts == 'true' }}" shell: bash - run: pnpm install --frozen-lockfile --ignore-scripts + run: | + cd ${{ inputs.cwd }} + pnpm install --frozen-lockfile --ignore-scripts diff --git a/package.json b/test/package.json similarity index 100% rename from package.json rename to test/package.json diff --git a/pnpm-lock.yaml b/test/pnpm-lock.yaml similarity index 100% rename from pnpm-lock.yaml rename to test/pnpm-lock.yaml