mirror of
https://github.com/actions/setup-java.git
synced 2026-08-01 16:22:58 +00:00
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:
+11
-2
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user