[CW-28153] fix: configure npm auth on runner before npm ci#40
Merged
Conversation
The unit_test job exposed NPM_TOKEN as an env var, but npm itself
does not read NPM_TOKEN — it expects an `.npmrc` line that
references `${NPM_TOKEN}`. The old docker-based workflow worked
because each service repo's Dockerfile wrote `.npmrc` at image
build time; on the runner there is no such step, so `npm ci` hit
401 Unauthorized against npm.pkg.github.com for private
@CoolBitX-Technology packages.
Add a `Configure npm auth` step that appends the GitHub Packages
auth line to ~/.npmrc before `npm ci` runs, matching the
Dockerfile's behavior.
Verified against the failing run from cp-user-registration:
https://github.com/CoolBitX-Technology/cp-user-registration/actions/runs/25309932225/job/74194197241
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Static Code Review 📊 ✅ All quality checks passed! |
GinaYYoung
approved these changes
May 4, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Configure npm authstep that writes//npm.pkg.github.com/:_authToken=${NPM_TOKEN}to~/.npmrcbeforenpm ciruns.NPM_TOKENenv from theInstall dependenciesstep to the new auth step (npm itself never read that env var; only the.npmrcline uses it).Why
Previously the
unit_testjob setNPM_TOKENas an env var on thenpm cistep, expecting npm to pick it up. It doesn't — npm only honours.npmrcentries that reference${NPM_TOKEN}. The old docker-based workflow worked because each service repo's Dockerfile wrote.npmrcat image build time. On the runner there's no such step, sonpm cihits 401 Unauthorized againstnpm.pkg.github.comfor private@CoolBitX-Technologypackages.Failing run that surfaced this: https://github.com/CoolBitX-Technology/cp-user-registration/actions/runs/25309932225/job/74194197241
Test Plan
cp-user-registration那條 branch 的 CI,確認unit_testjob 通過npm ci並進入npm testbuild_imagejob 行為不變(artifact 仍正常上傳)cp-user-registration特例Related
docs/plans/2026-05-04-unit-test-then-build-workflow.mdPR Summary by Typo
Overview
This PR addresses an issue in the CI pipeline where npm authentication was not properly configured before dependency installation, causing
npm cito fail when accessing private packages.Key Changes
unit_test_than_build_image.ymlGitHub Actions workflow to configure npm authentication.DEVOPS_READ_PACKAGE_TOKENto the.npmrcfile, ensuring authentication is set up beforenpm ciruns.Work Breakdown
To turn off PR summary, please visit Notification settings.