Add read-only dependency cache mode (#1169)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b3f6f152-8ac4-4c29-b04a-acac8e100777
This commit is contained in:
Bruno Borges
2026-07-29 10:20:14 -04:00
committed by GitHub
parent bcd3ba3d32
commit 62f345fa33
8 changed files with 138 additions and 4 deletions
+11 -2
View File
@@ -1,7 +1,7 @@
import * as core from '@actions/core';
import * as gpg from './gpg.js';
import * as constants from './constants.js';
import {isJobStatusSuccess} from './util.js';
import {getBooleanInput, isJobStatusSuccess} from './util.js';
import {save} from './cache.js';
import {fileURLToPath} from 'url';
@@ -28,7 +28,16 @@ async function removePrivateKeyFromKeychain() {
async function saveCache() {
const jobStatus = isJobStatusSuccess();
const cache = core.getInput(constants.INPUT_CACHE);
return jobStatus && cache ? save(cache) : Promise.resolve();
if (!jobStatus || !cache) {
return;
}
if (getBooleanInput(constants.INPUT_CACHE_READ_ONLY, false)) {
core.info('Cache saving is skipped because cache-read-only is enabled.');
return;
}
await save(cache);
}
/**
+1
View File
@@ -38,6 +38,7 @@ export const GPG_PASSPHRASE_PROFILE_ID = 'setup-java-gpg';
export const INPUT_CACHE = 'cache';
export const INPUT_CACHE_DEPENDENCY_PATH = 'cache-dependency-path';
export const INPUT_CACHE_READ_ONLY = 'cache-read-only';
export const INPUT_JOB_STATUS = 'job-status';
export const STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint';