Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ inputs:
default: true
cache-dependency-path:
description: 'Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies.'
cache-write:
description: 'Whether to save the cache at the end of the workflow. Set to false for cache read-only mode, useful for preventing cache poisoning from untrusted PR builds.'
default: true
mirror:
description: 'Used to specify an alternative mirror to download Node.js binaries from'
mirror-token:
Expand Down
5 changes: 5 additions & 0 deletions dist/cache-save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71532,6 +71532,11 @@ process.on('uncaughtException', e => {
// Added early exit to resolve issue with slow post action step:
async function run(earlyExit) {
try {
const cacheWriteEnabled = core.getInput('cache-write');
if (cacheWriteEnabled === 'false') {
core.info('Cache write is disabled (read-only mode). Skipping cache save.');
return;
}
const cacheLock = core.getState(constants_1.State.CachePackageManager);
if (cacheLock) {
await cachePackages(cacheLock);
Expand Down
6 changes: 6 additions & 0 deletions src/cache-save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ process.on('uncaughtException', e => {
// Added early exit to resolve issue with slow post action step:
export async function run(earlyExit?: boolean) {
try {
const cacheWriteEnabled = core.getInput('cache-write');
if (cacheWriteEnabled === 'false') {
Comment on lines +19 to +20
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache-write is being treated as a raw string and only disables saving when the value is exactly 'false'. This is inconsistent with how other boolean-like inputs in this repo are parsed (case-insensitive), and it also misses values like FALSE / False / whitespace. Consider normalizing the input (e.g., (core.getInput('cache-write') || 'true').trim().toUpperCase() === 'TRUE') or switching to core.getBooleanInput so the behavior is reliably boolean.

Suggested change
const cacheWriteEnabled = core.getInput('cache-write');
if (cacheWriteEnabled === 'false') {
const cacheWriteInput = core.getInput('cache-write');
const cacheWriteEnabled =
(cacheWriteInput || 'true').trim().toUpperCase() === 'TRUE';
if (!cacheWriteEnabled) {

Copilot uses AI. Check for mistakes.
core.info('Cache write is disabled (read-only mode). Skipping cache save.');
return;
}
Comment on lines +19 to +25
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new core.getInput('cache-write') call changes run()'s observable behavior and will break existing unit tests that assert getInput is never called in cache-save (e.g. __tests__/cache-save.test.ts). Please update the tests accordingly and add a test that verifies setting cache-write: false skips cache.saveCache (and logs the info message).

Copilot uses AI. Check for mistakes.

const cacheLock = core.getState(State.CachePackageManager);

if (cacheLock) {
Expand Down
Loading