|
| 1 | +name: Setup node and pnpm |
| 2 | +description: | |
| 3 | + Configures Node, pnpm, cache, performs pnpm install |
| 4 | +
|
| 5 | +inputs: |
| 6 | + node-version: |
| 7 | + description: Node.js version |
| 8 | + required: true |
| 9 | + default: 22.6.0 |
| 10 | + pnpm-version: |
| 11 | + description: Pnpm version |
| 12 | + required: true |
| 13 | + default: 9.7.1 |
| 14 | + pnpm-run-install: |
| 15 | + description: Whether to run pnpm install |
| 16 | + required: false |
| 17 | + default: true |
| 18 | + pnpm-restore-cache: |
| 19 | + description: Whether to restore cache |
| 20 | + required: false |
| 21 | + default: true |
| 22 | + pnpm-install-cache-key: |
| 23 | + description: The cache key for the pnpm install cache |
| 24 | + default: pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 25 | + |
| 26 | +outputs: |
| 27 | + pnpm-store-path: |
| 28 | + description: The resolved pnpm store path |
| 29 | + pnpm-install-cache-key: |
| 30 | + description: The cache key used for pnpm install cache |
| 31 | + |
| 32 | +runs: |
| 33 | + using: composite |
| 34 | + steps: |
| 35 | + # https://github.com/actions/virtual-environments/issues/1187 |
| 36 | + - name: tune linux network |
| 37 | + shell: bash |
| 38 | + run: sudo ethtool -K eth0 tx off rx off |
| 39 | + |
| 40 | + - name: Setup Node@${{ inputs.node-version }} |
| 41 | + uses: actions/setup-node@v4 |
| 42 | + with: |
| 43 | + node-version: ${{ inputs.node-version }} |
| 44 | + |
| 45 | + - name: Install pnpm |
| 46 | + uses: pnpm/action-setup@v4 |
| 47 | + with: |
| 48 | + version: ${{ inputs.pnpm-version }} |
| 49 | + run_install: false |
| 50 | + |
| 51 | + - name: Get pnpm store path |
| 52 | + shell: bash |
| 53 | + run: | |
| 54 | + STORE_PATH=$(pnpm store path --silent) |
| 55 | + echo "STORE_PATH=$STORE_PATH" >> $GITHUB_ENV |
| 56 | + echo "Pnpm store path resolved to: $STORE_PATH" |
| 57 | +
|
| 58 | + - name: Restore pnpm install cache |
| 59 | + if: ${{ inputs.pnpm-restore-cache == 'true' }} |
| 60 | + uses: actions/cache@v4 |
| 61 | + with: |
| 62 | + path: ${{ env.STORE_PATH }} |
| 63 | + key: ${{ inputs.pnpm-install-cache-key }} |
| 64 | + restore-keys: | |
| 65 | + pnpm-store-${{ inputs.pnpm-version }}- |
| 66 | + pnpm-store- |
| 67 | +
|
| 68 | + - name: Run pnpm install |
| 69 | + if: ${{ inputs.pnpm-run-install == 'true' }} |
| 70 | + shell: bash |
| 71 | + run: pnpm install |
| 72 | + |
| 73 | + # Set the cache key output |
| 74 | + - run: | |
| 75 | + echo "pnpm-install-cache-key=${{ inputs.pnpm-install-cache-key }}" >> $GITHUB_ENV |
| 76 | + shell: bash |
0 commit comments