I want t use pnpm
instead of npm
in my Github Actions, so I replace npm
by pnpm
in the file below:
.github/workflows/build.yml
:
name: Generate a build and push to another branch
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
name: Build and Push
steps:
- name: git-checkout
uses: actions/checkout@v3
- name: Install all dependencies
run: pnpm install
- name: Build
run: pnpm run build # The build command of your project
- name: Push
uses: s0/git-publish-subdir-action@develop
env:
REPO: self
BRANCH: build # The branch name where you want to push the assets
FOLDER: dist # The directory where your assets are generated
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub will automatically add this - you don't need to bother getting a token
MESSAGE: "Build: ({sha}) {msg}" # The commit message
But I'm getting the following error:
Run pnpm install
/home/runner/work/_temp/bac64766-f49a-4c8a-840d-dcccab703179.sh: line 1: pnpm: command not found
Error: Process completed with exit code 127.
How should I modify my file to be able to use pnpm
instead of npm
?
npm is installed on runners by default, pnpm is not, this is why your workflow is failing.
To get pnpm installed on the runner, use https://github.com/pnpm/action-setup.
e.g.
name: Generate a build and push to another branch
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
name: Build and Push
steps:
- name: git-checkout
uses: actions/checkout@v3
- name: pnpm-setup
uses: pnpm/action-setup@v2
...