Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -20,6 +20,9 @@ inputs:
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
cache-dependency-path:
description: "Used to specify the path to dependency files. 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
update-environment:
description: "Set this option if you want the action to update environment variables."
default: true
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 @@ -44170,6 +44170,11 @@ const cache_distributor_1 = __nccwpck_require__(92326);
// https://github.com/actions/cache/pull/1217
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 cache = core.getInput('cache');
if (cache) {
await saveCache(cache);
Expand Down
8 changes: 8 additions & 0 deletions src/cache-save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import {State} from './cache-distributions/cache-distributor';
// https://github.com/actions/cache/pull/1217
export async function run(earlyExit?: boolean) {
try {
const cacheWriteEnabled = core.getInput('cache-write');
if (cacheWriteEnabled === 'false') {
Comment on lines +12 to +13
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 treated as a raw string and only disables saving when the value is exactly 'false'. This is inconsistent with other boolean inputs in this repo (e.g., check-latest uses core.getBooleanInput) and will silently save the cache for values like False/FALSE. Prefer core.getBooleanInput('cache-write') (or normalize/lowercase) and branch on the boolean result.

Suggested change
const cacheWriteEnabled = core.getInput('cache-write');
if (cacheWriteEnabled === 'false') {
const cacheWriteInput = core.getInput('cache-write');
const cacheWriteEnabled =
cacheWriteInput === ''
? true
: core.getBooleanInput('cache-write');
if (!cacheWriteEnabled) {

Copilot uses AI. Check for mistakes.
core.info(
'Cache write is disabled (read-only mode). Skipping cache save.'
);
return;
}

const cache = core.getInput('cache');
if (cache) {
await saveCache(cache);
Expand Down
Loading