Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/actions/setup-node-pnpm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Setup Node.js and pnpm Action

A reusable composite action that consolidates Node.js and pnpm installation steps for the Vibe Dashboard project.

## Features

- ✅ Sets up Node.js with configurable version (defaults to LTS)
- ✅ Sets up pnpm using the project's configured version
- ✅ Optional pnpm store caching for faster builds
- ✅ Automatic dependency installation with configurable lockfile mode
- ✅ Environment variable handling for GitHub tokens

## Usage

```yaml
steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm
with:
# Optional inputs
node-version: 'lts/*' # Default: 'lts/*'
enable-cache: true # Default: 'true'
frozen-lockfile: true # Default: 'true'
```

## Inputs

| Input | Description | Required | Default |
|-------|-------------|----------|---------|
| `node-version` | Node.js version to install | No | `'lts/*'` |
| `enable-cache` | Enable pnpm store caching | No | `'true'` |
| `frozen-lockfile` | Use frozen lockfile for pnpm install | No | `'true'` |

## What it does

1. **Setup Node.js**: Installs the specified Node.js version
2. **Setup pnpm**: Installs pnpm using the project's configured version (from `packageManager` field)
3. **Cache pnpm store** (optional): Sets up caching for pnpm store to speed up subsequent runs
4. **Install dependencies**: Runs `pnpm install` with optional `--frozen-lockfile` flag

## Examples

### CI/CD with caching and frozen lockfile
```yaml
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm
with:
enable-cache: true
frozen-lockfile: true
```

### Deployment without strict lockfile requirements
```yaml
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm
with:
enable-cache: false
frozen-lockfile: false
```

### Custom Node.js version
```yaml
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm
with:
node-version: '20'
enable-cache: true
frozen-lockfile: true
```
50 changes: 50 additions & 0 deletions .github/actions/setup-node-pnpm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 'Setup Node.js and pnpm'
description: 'Reusable action to setup Node.js and pnpm with caching'

inputs:
node-version:
description: 'Node.js version to install'
required: false
default: 'lts/*'
enable-cache:
description: 'Enable pnpm store caching'
required: false
default: 'true'
frozen-lockfile:
description: 'Use frozen lockfile for pnpm install'
required: false
default: 'true'

runs:
using: 'composite'
steps:
- name: Setup Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Get pnpm store directory
if: inputs.enable-cache == 'true'
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Setup pnpm cache
if: inputs.enable-cache == 'true'
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
shell: bash
run: pnpm install${{ inputs.frozen-lockfile == 'true' && ' --frozen-lockfile' || '' }}
env:
GITHUB_TOKEN: ${{ github.token }}
30 changes: 4 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v5

- name: Setup Node.js LTS
uses: actions/setup-node@v4
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm
with:
node-version: 'lts/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
enable-cache: true
frozen-lockfile: true

- name: Lint code
run: pnpm lint
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,11 @@ jobs:
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Setup Node.js
uses: actions/setup-node@v4
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm
with:
node-version: 'lts/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Install dependencies
run: pnpm install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
enable-cache: false
frozen-lockfile: false

- name: Run lint
run: pnpm lint
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v4
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm
with:
node-version: 'lts/*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Install dependencies
run: pnpm install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
enable-cache: false
frozen-lockfile: false

- name: Lint
run: pnpm lint
Expand Down