-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add pnpm composite install action
- Loading branch information
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
|
||
name: ⚙️ Monorepo install (pnpm) | ||
description: 'Run pnpm install with enabled cache.' | ||
|
||
inputs: | ||
cwd: | ||
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()" | ||
required: false | ||
default: '.' | ||
enable-corepack: | ||
description: 'Enable corepack' | ||
required: false | ||
default: 'false' | ||
cache-prefix: | ||
description: "Add a specific cache-prefix" | ||
required: false | ||
default: 'default' | ||
cache-node-modules: | ||
description: 'Cache node_modules, might speed up link step (invalidated lock/os/node-version/branch)' | ||
required: false | ||
default: 'false' | ||
|
||
runs: | ||
using: 'composite' | ||
|
||
steps: | ||
- name: ⚙️ Enable Corepack | ||
if: inputs.enable-corepack == 'true' | ||
shell: bash | ||
working-directory: ${{ inputs.cwd }} | ||
run: corepack enable | ||
|
||
- name: ⚙️ Install pnpm | ||
if: inputs.enable-corepack == 'false' | ||
uses: pnpm/action-setup@v2 | ||
id: pnpm-install | ||
with: | ||
run_install: false | ||
|
||
- name: 🌎 Expose pnpm config(s) through "$GITHUB_OUTPUT" | ||
id: pnpm-config | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path | tr -d '\n')" >> $GITHUB_OUTPUT | ||
echo "CURRENT_NODE_VERSION="node-$(node --version)"" >> $GITHUB_OUTPUT | ||
echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g')" >> $GITHUB_OUTPUT | ||
- name: ♻️ Cache rotation keys | ||
id: cache-rotation | ||
shell: bash | ||
run: | | ||
echo "YEAR_MONTH=$(/bin/date -u "+%Y%m")" >> $GITHUB_OUTPUT | ||
- name: 🗄️ Setup pnpm cache | ||
uses: actions/cache@v3 | ||
id: pnpm-store-cache | ||
with: | ||
path: ${{ steps.pnpm-config.outputs.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store-cache-${{ steps.cache-rotation.outputs.YEAR_MONTH }}- | ||
- name: ♻️ Restore node_modules | ||
if: inputs.cache-node-modules == 'true' | ||
id: pnpm-nm-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ inputs.cwd }}/**/node_modules | ||
key: pnpm-nm-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.pnpm-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.pnpm-config.outputs.CURRENT_BRANCH }}-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
pnpm-nm-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.pnpm-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.pnpm-config.outputs.CURRENT_BRANCH }}- | ||
- name: 📦 Install dependencies | ||
shell: bash | ||
run: pnpm install --no-frozen-lockfile --strict-peer-dependencies --prefer-offline | ||
env: | ||
HUSKY: '0' |