Skip to content

fix(pnpm-install): keep github-registry-token off disk#279

Merged
B4nan merged 1 commit into
mainfrom
fix/pnpm-install-no-token-on-disk
May 5, 2026
Merged

fix(pnpm-install): keep github-registry-token off disk#279
B4nan merged 1 commit into
mainfrom
fix/pnpm-install-no-token-on-disk

Conversation

@B4nan
Copy link
Copy Markdown
Member

@B4nan B4nan commented May 5, 2026

Summary

Reported by František on the apify-core pnpm migration review: the current github-registry-token flow writes the expanded token into ~/.npmrc, where any later step in the same job can read it. That's a regression vs the npm pattern this action replaced.

The npm pattern was two-step:

  1. npm config set '//npm.pkg.github.com/:_authToken=${APIFY_..._TOKEN}' — single quotes, the template (literal ${VAR}) lands in ~/.npmrc, not the actual value.
  2. npm install ran with env: APIFY_..._TOKEN: ${{ secrets... }} — npm expanded the template at fetch time using the env var, which only existed for that one step.

The token never touched disk, and was unreachable to any later step. This PR restores that behaviour for the composite:

  • Auth step writes the literal template '\${GITHUB_REGISTRY_TOKEN}' (single quotes — load-bearing) into ~/.npmrc.
  • The install step is the only one that sets GITHUB_REGISTRY_TOKEN in env:. pnpm expands the template at registry-fetch time, then the env var is gone.
  • After the install step, ~/.npmrc contains …_authToken=\${GITHUB_REGISTRY_TOKEN} — an unusable template. Anything compromised in a later step cannot read the token.

Compatibility

No input/output changes. Callers don't need to update anything.

Verification

  • apify-core#27608 already consumes @main and runs successfully against this token; once this lands the only behaviour change is the contents of ~/.npmrc (template instead of expanded value).

The token previously landed in ~/.npmrc as plain text, where any later
step in the same job could read it — a regression vs the npm pattern
this action replaced.

Instead, write the literal template '${GITHUB_REGISTRY_TOKEN}' into
~/.npmrc (single quotes, no shell expansion) and inject the env var
only for the install step. pnpm expands the template at registry-fetch
time; once the install step exits, the env var is gone and ~/.npmrc
holds an unusable template — later steps cannot exfiltrate the token.

Reported by František on the apify-core pnpm migration review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added this to the 140th sprint - Tooling team milestone May 5, 2026
@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label May 5, 2026
@B4nan B4nan requested a review from fnesveda May 5, 2026 13:37
@B4nan B4nan added the adhoc Ad-hoc unplanned task added during the sprint. label May 5, 2026
@B4nan B4nan merged commit aaa1a36 into main May 5, 2026
3 of 5 checks passed
@B4nan B4nan deleted the fix/pnpm-install-no-token-on-disk branch May 5, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants