How to use the @actions/tool-cache.cacheFile function in @actions/tool-cache

To help you get started, we’ve selected a few @actions/tool-cache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github anchore / scan-action / index.js View on Github external
async function downloadInlineScan(version) {
    core.debug(`Installing ${version}`);
    const downloadPath = await cache.downloadTool(`https://ci-tools.anchore.io/inline_scan-v${version}`);
    // Make sure the tool's executable bit is set
    await exec(`chmod +x ${downloadPath}`);

    // Cache the downloaded file
    return cache.cacheFile(downloadPath, scanScript, scanScript, version);
  }
github Azure / k8s-actions / setup-kubectl / lib / run.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
        let cachedToolpath = toolCache.find(kubectlToolName, version);
        let kubectlDownloadPath = '';
        if (!cachedToolpath) {
            try {
                kubectlDownloadPath = yield toolCache.downloadTool(getkubectlDownloadURL(version));
            }
            catch (exception) {
                throw new Error('DownloadKubectlFailed');
            }
            cachedToolpath = yield toolCache.cacheFile(kubectlDownloadPath, kubectlToolName + getExecutableExtension(), kubectlToolName, version);
        }
        const kubectlPath = path.join(cachedToolpath, kubectlToolName + getExecutableExtension());
        fs.chmodSync(kubectlPath, '777');
        return kubectlPath;
    });
}
github avsm / setup-ocaml / src / installer.ts View on Github external
async function acquireOpamLinux(version: string): Promise {
  let opamVersion: string = "2.0.5"
  let fileName: string = getOpamFileName(opamVersion);
  let downloadUrl: string = getOpamDownloadUrl(opamVersion, fileName);
  let downloadPath: string | null = null;
  try {
    downloadPath = await tc.downloadTool(downloadUrl);
  } catch (error) {
    core.debug(error);
    throw `Failed to download version ${opamVersion}: ${error}`;
  }
  fs.chmodSync(downloadPath, '755');
  let toolPath : string = await tc.cacheFile(downloadPath, 'opam', 'opam', opamVersion);
  core.addPath(toolPath);
  await exec.exec("sudo apt-get -y install bubblewrap ocaml-native-compilers ocaml-compiler-libs");
  await exec.exec(`"${toolPath}/opam"`, ["init", "-yav"]);
  await exec.exec(path.join(__dirname, 'install-ocaml-unix.sh'),[version]);
  await exec.exec(`"${toolPath}/opam"`, ["install", "-y", "depext"]);
}
github Azure / k8s-actions / setup-kubectl / src / run.ts View on Github external
async function downloadKubectl(version: string): Promise {
    let cachedToolpath = toolCache.find(kubectlToolName, version);
    let kubectlDownloadPath = '';
    if (!cachedToolpath) {
        try {
            kubectlDownloadPath = await toolCache.downloadTool(getkubectlDownloadURL(version));
        } catch (exception) {
            throw new Error('DownloadKubectlFailed');
        }

        cachedToolpath = await toolCache.cacheFile(kubectlDownloadPath, kubectlToolName + getExecutableExtension(), kubectlToolName, version);
    }

    const kubectlPath = path.join(cachedToolpath, kubectlToolName + getExecutableExtension());
    fs.chmodSync(kubectlPath, '777');
    return kubectlPath;
}
github avsm / setup-ocaml / src / installer.ts View on Github external
async function acquireOpamWindows(version: string): Promise {
  let downloadPath: string | null = null;
  let toolPath : string | null = null;
  try {
    downloadPath = await tc.downloadTool("https://cygwin.com/setup-x86_64.exe");
  } catch (error) {
    core.debug(error);
    throw `Failed to download cygwin: ${error}`;
  }
  toolPath = await tc.cacheFile(downloadPath, 'setup-x86_64.exe', 'cygwin', "1.0");
  await exec.exec(path.join(__dirname, 'install-ocaml-windows.cmd'),[__dirname, toolPath, version]);
  core.addPath("c:\\cygwin\\bin");
  core.addPath("c:\\cygwin\\wrapperbin");
}