feat: add option to not save cache (#851)

This commit is contained in:
Navneeth Jayendran 2024-04-24 18:17:21 -07:00 committed by GitHub
parent bf6479d5ec
commit c683728f10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 0 deletions

View File

@ -67,6 +67,10 @@ jobs:
# takes precedence over all other caching options. # takes precedence over all other caching options.
# skip-cache: true # skip-cache: true
# Optional: if set to true, caches will not be saved, but they may still be restored,
# subject to other options
# skip-save-cache: true
# Optional: if set to true, then the action won't cache or restore ~/go/pkg. # Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true # skip-pkg-cache: true

View File

@ -29,6 +29,12 @@ inputs:
takes precedence over all other caching options. takes precedence over all other caching options.
default: 'false' default: 'false'
required: false required: false
skip-save-cache:
description: |
if set to true then the action will not save any caches, but it may still
restore existing caches, subject to other options.
default: 'false'
required: false
skip-pkg-cache: skip-pkg-cache:
description: "if set to true then the action doesn't cache or restore ~/go/pkg." description: "if set to true then the action doesn't cache or restore ~/go/pkg."
default: 'false' default: 'false'

2
dist/post_run/index.js generated vendored
View File

@ -88900,6 +88900,8 @@ exports.restoreCache = restoreCache;
async function saveCache() { async function saveCache() {
if (core.getInput(`skip-cache`, { required: true }).trim() == "true") if (core.getInput(`skip-cache`, { required: true }).trim() == "true")
return; return;
if (core.getInput(`skip-save-cache`, { required: true }).trim() == "true")
return;
// Validate inputs, this can cause task failure // Validate inputs, this can cause task failure
if (!utils.isValidEvent()) { if (!utils.isValidEvent()) {
utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`); utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`);

2
dist/run/index.js generated vendored
View File

@ -88900,6 +88900,8 @@ exports.restoreCache = restoreCache;
async function saveCache() { async function saveCache() {
if (core.getInput(`skip-cache`, { required: true }).trim() == "true") if (core.getInput(`skip-cache`, { required: true }).trim() == "true")
return; return;
if (core.getInput(`skip-save-cache`, { required: true }).trim() == "true")
return;
// Validate inputs, this can cause task failure // Validate inputs, this can cause task failure
if (!utils.isValidEvent()) { if (!utils.isValidEvent()) {
utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`); utils.logWarning(`Event Validation Error: The event type ${process.env[constants_1.Events.Key]} is not supported because it's not tied to a branch or tag ref.`);

View File

@ -116,6 +116,7 @@ export async function restoreCache(): Promise<void> {
export async function saveCache(): Promise<void> { export async function saveCache(): Promise<void> {
if (core.getInput(`skip-cache`, { required: true }).trim() == "true") return if (core.getInput(`skip-cache`, { required: true }).trim() == "true") return
if (core.getInput(`skip-save-cache`, { required: true }).trim() == "true") return
// Validate inputs, this can cause task failure // Validate inputs, this can cause task failure
if (!utils.isValidEvent()) { if (!utils.isValidEvent()) {