Skip to content

Commit 28cfea2

Browse files
committed
cache-restore-only
1 parent db8764c commit 28cfea2

File tree

6 files changed

+30
-1
lines changed

6 files changed

+30
-1
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ inputs:
1717
default: true
1818
cache-dependency-path:
1919
description: 'Used to specify the path to a dependency file - go.sum'
20+
cache-restore-only:
21+
description: Used to specify the cache . Set to true, if you'd like to reuse existing cache but did not update it
22+
default: false
2023
architecture:
2124
description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.'
2225
outputs:

dist/cache-save/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58457,6 +58457,10 @@ process.on('uncaughtException', e => {
5845758457
});
5845858458
function run() {
5845958459
return __awaiter(this, void 0, void 0, function* () {
58460+
if (core.getState(constants_1.State.CacheRestoreOnly) === constants_1.State.True) {
58461+
core.info('"cache-restore-only" set to true, skip caching');
58462+
return;
58463+
}
5846058464
try {
5846158465
yield cachePackages();
5846258466
}
@@ -58622,6 +58626,9 @@ var State;
5862258626
(function (State) {
5862358627
State["CachePrimaryKey"] = "CACHE_KEY";
5862458628
State["CacheMatchedKey"] = "CACHE_RESULT";
58629+
State["CacheRestoreOnly"] = "CACHE_RESTORE_ONLY";
58630+
State["True"] = "true";
58631+
State["False"] = "false";
5862558632
})(State = exports.State || (exports.State = {}));
5862658633
var Outputs;
5862758634
(function (Outputs) {

dist/setup/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61292,6 +61292,9 @@ var State;
6129261292
(function (State) {
6129361293
State["CachePrimaryKey"] = "CACHE_KEY";
6129461294
State["CacheMatchedKey"] = "CACHE_RESULT";
61295+
State["CacheRestoreOnly"] = "CACHE_RESTORE_ONLY";
61296+
State["True"] = "true";
61297+
State["False"] = "false";
6129561298
})(State = exports.State || (exports.State = {}));
6129661299
var Outputs;
6129761300
(function (Outputs) {
@@ -61690,6 +61693,7 @@ const cache_utils_1 = __nccwpck_require__(1678);
6169061693
const child_process_1 = __importDefault(__nccwpck_require__(2081));
6169161694
const fs_1 = __importDefault(__nccwpck_require__(7147));
6169261695
const os_1 = __importDefault(__nccwpck_require__(2037));
61696+
const constants_1 = __nccwpck_require__(9042);
6169361697
function run() {
6169461698
return __awaiter(this, void 0, void 0, function* () {
6169561699
try {
@@ -61727,6 +61731,8 @@ function run() {
6172761731
core.debug(`add bin ${added}`);
6172861732
const goPath = yield io.which('go');
6172961733
const goVersion = (child_process_1.default.execSync(`${goPath} version`) || '').toString();
61734+
const cacheRestoreOnly = core.getBooleanInput('cache-restore-only');
61735+
core.saveState(constants_1.State.CacheRestoreOnly, cacheRestoreOnly ? constants_1.State.True : constants_1.State.False);
6173061736
if (cache && cache_utils_1.isCacheFeatureAvailable()) {
6173161737
const packageManager = 'default';
6173261738
const cacheDependencyPath = core.getInput('cache-dependency-path');

src/cache-save.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ process.on('uncaughtException', e => {
1313
});
1414

1515
export async function run() {
16+
if (core.getState(State.CacheRestoreOnly) === State.True) {
17+
core.info('"cache-restore-only" set to true, skip caching');
18+
return;
19+
}
1620
try {
1721
await cachePackages();
1822
} catch (error) {

src/constants.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
export enum State {
22
CachePrimaryKey = 'CACHE_KEY',
3-
CacheMatchedKey = 'CACHE_RESULT'
3+
CacheMatchedKey = 'CACHE_RESULT',
4+
CacheRestoreOnly = 'CACHE_RESTORE_ONLY',
5+
True = 'true',
6+
False = 'false'
47
}
58

69
export enum Outputs {

src/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {isCacheFeatureAvailable} from './cache-utils';
88
import cp from 'child_process';
99
import fs from 'fs';
1010
import os from 'os';
11+
import {State} from './constants';
1112

1213
export async function run() {
1314
try {
@@ -64,6 +65,11 @@ export async function run() {
6465
const goPath = await io.which('go');
6566
const goVersion = (cp.execSync(`${goPath} version`) || '').toString();
6667

68+
const cacheRestoreOnly = core.getBooleanInput('cache-restore-only');
69+
core.saveState(
70+
State.CacheRestoreOnly,
71+
cacheRestoreOnly ? State.True : State.False
72+
);
6773
if (cache && isCacheFeatureAvailable()) {
6874
const packageManager = 'default';
6975
const cacheDependencyPath = core.getInput('cache-dependency-path');

0 commit comments

Comments
 (0)