Skip to content
This repository was archived by the owner on Oct 27, 2022. It is now read-only.

Commit 6de3b4e

Browse files
committed
only run post step if data should be cached
1 parent f080526 commit 6de3b4e

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

lib/installer.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ let Installer = /** @class */ (() => {
8888
if (this._config.cacheMode === "default" /* Default */) {
8989
yield this.storeCache();
9090
}
91+
else {
92+
core_1.saveState(Installer.CacheStateKey, "true");
93+
}
9194
}
9295
else {
9396
yield this._platform.runPostInstall(true, toolPath);
@@ -117,7 +120,8 @@ let Installer = /** @class */ (() => {
117120
}
118121
post() {
119122
return __awaiter(this, void 0, void 0, function* () {
120-
if (this._config.cacheMode === "post" /* Post */) {
123+
const shouldCache = core_1.getState(Installer.CacheStateKey);
124+
if (this._config.cacheMode === "post" /* Post */ && shouldCache === "true") {
121125
yield this.storeCache();
122126
}
123127
});
@@ -212,6 +216,7 @@ let Installer = /** @class */ (() => {
212216
});
213217
}
214218
}
219+
Installer.CacheStateKey = "cache-result";
215220
Installer.CacheDir = path_1.join(".cache", "qt");
216221
return Installer;
217222
})();

src/installer.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ import { exists as existsCb } from "fs";
44
import { URL } from "url";
55
import { promisify } from "util";
66

7-
import { debug, info, setOutput, addPath, warning } from "@actions/core";
7+
import {
8+
debug,
9+
info,
10+
setOutput,
11+
addPath,
12+
warning,
13+
saveState,
14+
getState,
15+
} from "@actions/core";
816
import { mv, rmRF, mkdirP, which } from "@actions/io";
917
import { exec } from "@actions/exec";
1018
import { restoreCache, saveCache } from "@actions/cache";
@@ -22,7 +30,9 @@ import { Config, CacheMode } from "./config";
2230
const exists = promisify(existsCb);
2331

2432
export default class Installer {
33+
private static CacheStateKey = "cache-result";
2534
private static CacheDir = join(".cache", "qt");
35+
2636
private readonly _config: Config;
2737
private readonly _platform: IPlatform;
2838
private readonly _cacheKey: string;
@@ -106,6 +116,8 @@ export default class Installer {
106116
await this._platform.runPostInstall(false, toolPath);
107117
if (this._config.cacheMode === CacheMode.Default) {
108118
await this.storeCache();
119+
} else {
120+
saveState(Installer.CacheStateKey, "true");
109121
}
110122
} else {
111123
await this._platform.runPostInstall(true, toolPath);
@@ -144,7 +156,8 @@ export default class Installer {
144156
}
145157

146158
public async post(): Promise<void> {
147-
if (this._config.cacheMode === CacheMode.Post) {
159+
const shouldCache = getState(Installer.CacheStateKey);
160+
if (this._config.cacheMode === CacheMode.Post && shouldCache === "true") {
148161
await this.storeCache();
149162
}
150163
}

0 commit comments

Comments
 (0)