Install Netlify CLI from the lockfile in deploy jobs instead of an uncached global npm install

Open Beginner friendly
#274 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
github-actions
Domain
ci-cd

Research direction

Read .github/workflows/ci.yml and compare the build, deploy-preview, and deploy-production jobs. Replace the global Netlify CLI install and cache with the lockfile-based install, then check that the env-var and deploy steps invoke the local CLI. Done when both deploy jobs use the pinned CLI and no global Netlify install or related cache remains.

Written by the indexing model from the issue text.

Description

area:infra enhancement needs-triage

Summary

Install Netlify CLI in the deploy jobs from the lockfile-pinned devDependency instead of npm install -g netlify-cli, and remove the ~/.npm cache step, which doesn't do its job.

Affected files / area

  • .github/workflows/ci.yml: deploy-preview and deploy-production jobs (steps "Cache npm global packages", "Install Netlify CLI", and the netlify calls after them)

Proposed approach

"Install Netlify CLI" takes 36s in deploy-preview (run 46856330159), and the same step runs in deploy-production. The existing cache doesn't help it:

  • The key npm-global-${{ runner.os }}-netlify-cli never changes. actions/cache never overwrites an existing key, so the cache was saved once and is now frozen.
  • npm install -g netlify-cli isn't pinned, so it resolves the latest release on every run, and less of it matches the frozen cache over time. Deploys can also pick up a new CLI version unannounced.

netlify-cli is already a devDependency, pinned in pnpm-lock.yaml at 24.3.0. The build job's pnpm install --ignore-scripts, which includes it, takes about 8s without any cache. So:

  1. In both deploy jobs, replace "Cache npm global packages" and "Install Netlify CLI" with the same install the build job uses: npm install -g pnpm && pnpm install --ignore-scripts.
  2. Call the CLI with pnpm exec netlify … (or add node_modules/.bin to PATH) in "Set Netlify Env Vars" / "Set Netlify Env Var for Production" and "Deploy to Netlify".
  3. Optional: cache the pnpm store keyed on hashFiles('pnpm-lock.yaml') (e.g. pnpm/action-setup followed by actions/setup-node with cache: pnpm) to save a few more seconds.

Side effect: deploys will use the lockfile's Netlify CLI version rather than the latest. That is intended: it makes deploys reproducible, and the CLI gets bumped like any other dependency.

Acceptance criteria / verification

  • The CLI install step in deploy-preview takes ~10s or less instead of ~36s
  • deploy-preview still sets the env vars, deploys, and posts the preview link comment on a PR
  • deploy-production uses the same install, checked by reading the diff; it only runs on push to main
  • No npm install -g netlify-cli or npm-global-*-netlify-cli cache remains in the workflows
  • Pre-commit hooks pass

Dependencies

None.


Generated by Claude Code

Dominant language
HTML
Stars
0
Forks
0
Avg merge
48m
Merged PRs (30d)
47

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from UkuleleTuesday/website

All issues in UkuleleTuesday/website

Similar issues

More DevOps issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.