How to use the @actions/core.addPath function in @actions/core

To help you get started, we’ve selected a few @actions/core 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 warrenbuckley / Setup-Nuget / src / main.ts View on Github external
// Download latest Nuget.exe
    core.debug("Downloading Nuget tool");
    const nugetPath = await tc.downloadTool("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe");

    // Rename the file which is a GUID without extension
    var folder = path.dirname(nugetPath);
    var fullPath = path.join(folder, "nuget.exe");
    fs.renameSync(nugetPath, fullPath);

    //Cache the directory with Nuget in it - which returns a NEW cached location
    var cachedToolDir = await tc.cacheDir(folder, "nuget", "latest");
    core.debug(`Cached Tool Dir ${cachedToolDir}`);

    // Add Nuget.exe CLI tool to path for other steps to be able to access it
    await core.addPath(cachedToolDir);

  } catch (error) {
    core.setFailed(error.message);
  }
}
github r-lib / actions / setup-tinytex / src / setup-tinytex.ts View on Github external
await exec.exec("sh", [path.join(tempDirectory, fileName)]);

  let binPath: string;

  // The binaries are in TinyTeX/bin/*/, where the wildcard is the
  // architecture, but we should always take the first one.
  if (IS_MAC) {
    binPath = path.join(process.env["HOME"] || "/", "Library/TinyTeX/bin");
  } else {
    binPath = path.join(process.env["HOME"] || "/", ".TinyTeX/bin");
  }

  const arch = fs.readdirSync(binPath)[0];

  core.addPath(path.join(binPath, arch));
}
github matootie / dokube / index.js View on Github external
// Save the kubeconfig object.
    const formattedConfig = JSON.stringify(kubeconfig, null, 4);
    fs.writeFileSync(`${workdir}/kubeconfig`, formattedConfig);

    // Download and install kubectl.
    const kubectl = await tc.downloadTool("https://storage.googleapis.com/kubernetes-release/release/v1.16.0/bin/linux/amd64/kubectl");
    await io.mv(kubectl, `${workdir}/kubectl`);

    // Cache kubectl and kubeconfig.
    const cachedPath = await tc.cacheDir(workdir, 'kubectl', 'v1.16.0');

    // Set KUBECONFIG environment variable.
    core.exportVariable('KUBECONFIG', `${cachedPath}/kubeconfig`);

    // Add kubectl to PATH.
    core.addPath(`${cachedPath}/kubectl`);
  }
  catch (error) {
    core.setFailed(error.message);
  }
}
github warrenbuckley / Setup-MSBuild / src / main.ts View on Github external
core.setFailed("MSBuild.exe only works for Windows.");
      return;
    }

    // Try & find tool in cache
    let directoryToAddToPath:string;
    directoryToAddToPath = await tc.find("vswhere", "2.7.1");

    if(directoryToAddToPath){
      core.debug(`Found local cached tool at ${directoryToAddToPath} adding that to path`);

      var msBuildPath = await FindMSBuild(directoryToAddToPath);
      core.debug(`MSBuildPath == ${msBuildPath}`);

      // Add folder where MSBuild lives to the PATH
      await core.addPath(msBuildPath);
      return;
    }

    // Download VSWhere 2.7.1 release
    core.debug("Downloading VSWhere v2.7.1 tool");
    const vsWherePath = await tc.downloadTool("https://github.com/microsoft/vswhere/releases/download/2.7.1/vswhere.exe");

    // Rename the file which is a GUID without extension
    var folder = path.dirname(vsWherePath);
    var fullPath = path.join(folder, "vswhere.exe");
    fs.renameSync(vsWherePath, fullPath);

    //Cache the directory with VSWhere in it - which returns a NEW cached location
    var cachedToolDir = await tc.cacheDir(folder, "vswhere", "2.7.1");
    core.debug(`Cached Tool Dir ${cachedToolDir}`);
github newrelic / newrelic-ruby-agent / .github / actions / build-ruby / index.js View on Github external
function addRubyToPath(rubyVersion) {
  core.addPath(`${rubyPath(rubyVersion)}/bin`)
}
github clupprich / ruby-build-action / src / index.js View on Github external
async function _installRuby(rubyVersion, cacheAvailable) {
  core.startGroup(`Installing ${rubyVersion}`)

  if (!cacheAvailable) {
    await exec.exec(`ruby-build ${rubyVersion} ${process.env.HOME}/local/rubies/${rubyVersion}`)
  } else {
    core.info(`Skipping installation of ${rubyVersion}, already available in cache.`)
  }

  core.addPath(`${process.env.HOME}/local/rubies/${rubyVersion}/bin`)
  const rubyPath = await io.which('ruby', true)
  await exec.exec(`${rubyPath} --version`)
  core.setOutput('ruby-path', rubyPath);

  core.endGroup()
}
github maierj / fastlane-action / main.js View on Github external
function setupRubyGemsIfNecessary() {
    if (!shell.which("gem")) {
        const rubyInstallationDirectory = tc.find('Ruby', '2.6.3');
        const rubyBinaryDirectory = `${rubyInstallationDirectory}/bin`;
        core.addPath(rubyBinaryDirectory);
    }
}
github mstksg / setup-stack / index.js View on Github external
var dlcommand;

  switch(os.platform()) {
    case "linux":
      dlcommand = "curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C " + installdir + " '*/stack'";
      break;
    case "darwin":
      dlcommand = "curl --insecure -L https://get.haskellstack.org/stable/osx-x86_64.tar.gz | tar xz --strip-components=1 --include '*/stack' -C " + installdir;
      break;
    default:
      core.setFailed("Unsopported OS");
  }

  if (dlcommand) {
    child_process.execSync(dlcommand);
    core.addPath(installdir);
    child_process.execSync(installdir + "/stack", ["update"]);
  }
} catch (error) {
    core.setFailed(error.message);
}
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"]);
}