mirror of
https://github.com/seepine/action-setup-pnpm.git
synced 2024-10-12 15:19:54 +08:00
66 lines
1.9 KiB
YAML
66 lines
1.9 KiB
YAML
name: 'PNPM install'
|
|
description: 'Setup pnpm and run pnpm install with cache enabled'
|
|
|
|
inputs:
|
|
run_install:
|
|
description: If specified, run `pnpm install`
|
|
required: false
|
|
default: 'true'
|
|
cwd:
|
|
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()"
|
|
required: false
|
|
default: '.'
|
|
|
|
runs:
|
|
using: 'composite'
|
|
steps:
|
|
# If you want to set pnpm version, setting the packageManager field in package.json like "packageManager":"pnpm@8.10.2"
|
|
- name: ⚙️ Enable Corepack
|
|
shell: bash
|
|
working-directory: ${{ inputs.cwd }}
|
|
run: |
|
|
corepack enable
|
|
corepack enable npm
|
|
echo "corepack enabled"
|
|
echo "pnpm version : $(pnpm -v)"
|
|
echo "pnpm store path : $(pnpm store path)"
|
|
|
|
- name: Expose pnpm config(s) through "$GITHUB_OUTPUT"
|
|
id: pnpm-config
|
|
shell: bash
|
|
run: |
|
|
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Cache rotation keys
|
|
id: cache-rotation
|
|
shell: bash
|
|
run: |
|
|
echo "YEAR_MONTH=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT
|
|
|
|
- uses: seepine/hash-files@v1
|
|
name: Get hash of lock files
|
|
id: get-hash
|
|
with:
|
|
patterns: |
|
|
**/pnpm-lock.yaml
|
|
|
|
- uses: actions/cache@v3
|
|
name: Setup pnpm cache
|
|
with:
|
|
path: ${{ steps.pnpm-config.outputs.STORE_PATH }}
|
|
key: ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-${{ steps.get-hash.outputs.hash }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-
|
|
|
|
- name: Install dependencies
|
|
if: ${{ inputs.run_install == 'true' }}
|
|
shell: bash
|
|
working-directory: ${{ inputs.cwd }}
|
|
run: pnpm install --frozen-lockfile --prefer-offline
|
|
env:
|
|
HUSKY: '0'
|
|
|
|
- run: |
|
|
echo ""
|
|
echo "Setup pnpm finish."
|