Skip to content

Conversation

@hoegertn
Copy link
Contributor

@hoegertn hoegertn commented Jan 29, 2026

Description

This PR adds support for automatically setting up pnpm in GitHub Actions workflows when a project uses pnpm as its package manager.

Changes

  • New PnpmSetupStep class: A pipeline step that uses the pnpm/action-setup GitHub Action to install and configure pnpm before running install commands
  • New PnpmSetupStepOptions interface: Configuration options for the pnpm setup step, including an optional version parameter (defaults to '9')
  • Automatic injection: The PnpmSetupStep is automatically injected into the install step sequence when:
    • The project uses pnpm as its package manager
    • The pipeline engine is GitHub Actions
  • pnpm package installation support: Added support for installing packages via pnpm add command in the CDK pipeline base class
  • API documentation: Updated API.md with documentation for the new classes and interfaces

Implementation Details

  • The step is added to the pre-install step sequence in CDKPipeline.provideInstallStep()
  • The pnpm version can be customized via PnpmSetupStepOptions, with a sensible default of version '9'
  • The implementation follows the existing pattern used by other pipeline steps
  • Currently supports GitHub Actions; other CI/CD platforms can be added in the future by implementing additional to*() methods

Testing

The changes ensure that pnpm projects will have pnpm properly installed and available in their GitHub Actions workflows before any package installation commands are executed.

This commit implements automatic pnpm support for GithubCDKPipeline:

- Created PnpmSetupStep class that uses pnpm/action-setup@v4 GitHub Action
- Modified provideInstallStep() to automatically inject pnpm setup when:
  - Package manager is set to pnpm
  - Pipeline engine is GitHub
- Updated renderInstallPackageCommands() to support pnpm package installation
- Automatically uses pnpmVersion from project configuration if available

The pnpm setup step is now automatically added to all workflow jobs:
- synth jobs
- assetUpload jobs
- deploy-* jobs

This fixes the "npx: command not found: pnpm" error when projects use
pnpm as their package manager.

Fixes #161
@github-actions github-actions bot requested a review from Lock128 January 29, 2026 10:50
@hoegertn hoegertn changed the title Add pnpm setup step for GitHub Actions workflows feat: add pnpm setup step for GitHub Actions workflows Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants