How to use the @actions/exec.exec function in @actions/exec

To help you get started, we’ve selected a few @actions/exec 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 jimhester / setup-r / src / installer.ts View on Github external
core.debug(error);

    throw `Failed to install R: ${error}`;
  }

  //
  // Add symlinks to the installed R to the path
  //
  //
  try {
    await exec.exec("sudo ln", [
      "-s",
      path.join("/opt", "R", version, "bin", "R"),
      "/usr/local/bin/R"
    ]);
    await exec.exec("sudo ln", [
      "-s",
      path.join("/opt", "R", version, "bin", "Rscript"),
      "/usr/local/bin/Rscript"
    ]);
  } catch (error) {
    core.debug(error);

    throw `Failed to setup symlinks to R: ${error}`;
  }

  return "/usr/local/bin";
}
github jimhester / setup-r / src / installer.ts View on Github external
} catch (error) {
    core.debug(error);

    throw `Failed to download version ${version}: ${error}`;
  }

  //
  // Install
  //
  let extPath: string = tempDirectory;
  if (!extPath) {
    throw new Error("Temp directory not set");
  }

  try {
    await exec.exec(path.join(tempDirectory, fileName), [
      "/VERYSILENT",
      "/SUPPRESSMSGBOXES",
      "/DIR=C:\\R"
    ]);
  } catch (error) {
    core.debug(error);

    throw `Failed to install R: ${error}`;
  }

  core.addPath(`C:\\R\\bin`);

  return "";
}
github r-lib / actions / setup-tinytex / src / setup-tinytex.ts View on Github external
}
  }

  const fileName = "install-unx.sh";
  const downloadUrl = "https://yihui.name/gh/tinytex/tools/install-unx.sh";
  let downloadPath: string | null = null;

  try {
    downloadPath = await tc.downloadTool(downloadUrl);
  } catch (error) {
    throw `Failed to download TinyTex: ${error}`;
  }

  await io.mv(downloadPath, path.join(tempDirectory, fileName));

  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 newrelic / newrelic-ruby-agent / .github / actions / build-ruby / index.js View on Github external
async function downgradeMySQL() {
  core.startGroup(`Downgrade MySQL`)

  const pkgDir = `${process.env.HOME}/packages`
  const pkgOption = `--directory-prefix=${pkgDir}/`
  const mirrorUrl = 'https://mirrors.mediatemple.net/debian-security/pool/updates/main/m/mysql-5.5'
  const ubuntuUrl = 'http://archive.ubuntu.com/ubuntu/pool/main'

  // executes the following all in parallel  
  const promise1 = exec.exec('sudo', ['apt-get', 'remove', 'mysql-client'])
  const promise2 = exec.exec('wget', [pkgOption, `${mirrorUrl}/libmysqlclient18_5.5.62-0%2Bdeb8u1_amd64.deb`])
  const promise3 = exec.exec('wget', [pkgOption, `${mirrorUrl}/libmysqlclient-dev_5.5.62-0%2Bdeb8u1_amd64.deb`])
  const promise4 = exec.exec('wget', [pkgOption, `${ubuntuUrl}/g/glibc/multiarch-support_2.27-3ubuntu1.2_amd64.deb`])

  // wait for the parallel processes to finish
  await Promise.all([promise1, promise2, promise3, promise4])

  // executes serially
  await exec.exec('sudo', ['dpkg', '-i', `${pkgDir}/multiarch-support_2.27-3ubuntu1.2_amd64.deb`])
  await exec.exec('sudo', ['dpkg', '-i', `${pkgDir}/libmysqlclient18_5.5.62-0+deb8u1_amd64.deb`])
  await exec.exec('sudo', ['dpkg', '-i', `${pkgDir}/libmysqlclient-dev_5.5.62-0+deb8u1_amd64.deb`])

  core.endGroup()
}
github enriikke / gatsby-gh-pages-action / index.js View on Github external
await exec.exec(`git init`, [], { cwd: "./public" })
    await exec.exec(`git config user.name`, [github.context.actor], {
      cwd: "./public",
    })
    await exec.exec(
      `git config user.email`,
      [`${github.context.actor}@users.noreply.github.com`],
      { cwd: "./public" }
    )
    await exec.exec(`git add`, ["."], { cwd: "./public" })
    await exec.exec(
      `git commit`,
      ["-m", `deployed via Gatsby Publish Action 🎩 for ${github.context.sha}`],
      { cwd: "./public" }
    )
    await exec.exec(`git push`, ["-f", repoURL, `master:${deployBranch}`], {
      cwd: "./public",
    })
    console.log("Finished deploying your site.")

    console.log("Enjoy! ✨")
  } catch (error) {
    core.setFailed(error.message)
  }
}
github newrelic / newrelic-ruby-agent / .github / actions / build-ruby / index.js View on Github external
async function upgradeRubyGems(rubyVersion) {
  core.startGroup(`Upgrade RubyGems`)

  await execute('gem --version').then(res => { gemVersionStr = res; });

  console.log(`Current RubyGems is "${gemVersionStr}"`)

  if (parseFloat(rubyVersion) < 2.7) {

    if (parseFloat(gemVersionStr) < 3.0) {
      console.log(`Ruby < 2.7, upgrading RubyGems from ${gemVersionStr}`)

      await exec.exec('gem', ['update', '--system', '3.0.6', '--force']).then(res => { exitCode = res });
      if (exitCode != 0) {
        await exec.exec('gem', ['install', 'rubygems-update', '-v', '<3'])
        await exec.exec('update_rubygems')
      };
      
    }
    else {
      console.log(`Ruby < 2.7, but RubyGems already at ${gemVersionStr}`)
    }
  } 

  else {
    console.log(`Ruby >= 2.7, keeping RubyGems at ${gemVersionStr}`)
  }

  await execute('which gem').then(res => { console.log("which gem: " + res) });
  await execute('gem --version').then(res => { console.log("New RubyGems is: " + res) });
github newrelic / newrelic-ruby-agent / .github / actions / build-ruby / index.js View on Github external
async function upgradeRubyGems(rubyVersion) {
  core.startGroup(`Upgrade RubyGems`)

  await execute('gem --version').then(res => { gemVersionStr = res; });

  console.log(`Current RubyGems is "${gemVersionStr}"`)

  if (parseFloat(rubyVersion) < 2.7) {

    if (parseFloat(gemVersionStr) < 3.0) {
      console.log(`Ruby < 2.7, upgrading RubyGems from ${gemVersionStr}`)

      await exec.exec('gem', ['update', '--system', '3.0.6', '--force']).then(res => { exitCode = res });
      if (exitCode != 0) {
        await exec.exec('gem', ['install', 'rubygems-update', '-v', '<3'])
        await exec.exec('update_rubygems')
      };
      
    }
    else {
      console.log(`Ruby < 2.7, but RubyGems already at ${gemVersionStr}`)
    }
  } 

  else {
    console.log(`Ruby >= 2.7, keeping RubyGems at ${gemVersionStr}`)
  }

  await execute('which gem').then(res => { console.log("which gem: " + res) });
  await execute('gem --version').then(res => { console.log("New RubyGems is: " + res) });

  core.endGroup()
github avsm / setup-ocaml / src / installer.ts View on Github external
async function acquireOpamDarwin(version: string): Promise {
  await exec.exec ("brew install ocaml opam");
  await exec.exec("opam", ["init", "-yav"]);
  await exec.exec(path.join(__dirname, 'install-ocaml-unix.sh'),[version]);
  await exec.exec("opam", ["install", "-y", "depext"]);
}
github newrelic / newrelic-ruby-agent / .github / actions / build-ruby / index.js View on Github external
async function showVersions() {
  core.startGroup("Show Versions")

  await exec.exec('ruby', ['--version'])
  await exec.exec('ruby', ['-ropenssl', '-e', "puts OpenSSL::OPENSSL_LIBRARY_VERSION"])
  await exec.exec('gem', ['--version'])
  await exec.exec('bundle', ['--version'])
  await exec.exec('openssl', ['version'])

  core.endGroup()
}
github hecrj / setup-rust-action / src / rustup.ts View on Github external
async function installOnUnix(): Promise {
  let script = await toolCache.downloadTool("https://sh.rustup.rs");

  chmodSync(script, '777');
  await exec.exec(`"${script}"`, ['-y', '--default-toolchain', 'none', '--profile=minimal']);

  return path.join(process.env['HOME'] || '', '.cargo');
}