mirror of
https://github.com/actions/setup-node.git
synced 2026-03-16 07:25:46 +01:00
feat: add cache-write input for read-only cache mode
Add a 'cache-write' input (default: true) that controls whether the cache is saved at the end of the workflow. When set to 'false', the action will restore cached dependencies but skip saving, providing a read-only cache mode. This is useful for preventing cache poisoning attacks from untrusted PR builds while still benefiting from cached dependencies.
This commit is contained in:
parent
53b83947a5
commit
974c02c884
3 changed files with 14 additions and 0 deletions
|
|
@ -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') {
|
||||
core.info('Cache write is disabled (read-only mode). Skipping cache save.');
|
||||
return;
|
||||
}
|
||||
|
||||
const cacheLock = core.getState(State.CachePackageManager);
|
||||
|
||||
if (cacheLock) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue