How to use the @actions/core.setOutput 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 codfish / semantic-release-action / entrypoint.js View on Github external
core.debug(`The last release was "${lastRelease.version}".`);
  }

  // outputs
  const { version } = nextRelease;
  const major = version.split('.')[0];
  const minor = version.split('.')[1];
  const patch = version.split('.')[2];

  // set outputs
  core.exportVariable('NEW_RELEASE_PUBLISHED', 'true');
  core.exportVariable('RELEASE_VERSION', version);
  core.exportVariable('RELEASE_MAJOR', major);
  core.exportVariable('RELEASE_MINOR', minor);
  core.exportVariable('RELEASE_PATCH', patch);
  core.setOutput('new-release-published', 'true');
  core.setOutput('release-version', version);
  core.setOutput('release-major', major);
  core.setOutput('release-minor', minor);
  core.setOutput('release-patch', patch);
}
github aws-actions / amazon-ecs-deploy-task-definition / index.js View on Github external
const appSpecHash = crypto.createHash('sha256').update(appSpecString).digest('hex');

  // Start the deployment with the updated appspec contents
  core.debug('Starting CodeDeploy deployment');
  const createDeployResponse = await codedeploy.createDeployment({
    applicationName: codeDeployApp,
    deploymentGroupName: codeDeployGroup,
    revision: {
      revisionType: 'AppSpecContent',
      appSpecContent: {
        content: appSpecString,
        sha256: appSpecHash
      }
    }
  }).promise();
  core.setOutput('codedeploy-deployment-id', createDeployResponse.deploymentId);

  // Wait for deployment to complete
  if (waitForService && waitForService.toLowerCase() === 'true') {
    // Determine wait time
    const deployReadyWaitMin = deploymentGroupDetails.blueGreenDeploymentConfiguration.deploymentReadyOption.waitTimeInMinutes;
    const terminationWaitMin = deploymentGroupDetails.blueGreenDeploymentConfiguration.terminateBlueInstancesOnDeploymentSuccess.terminationWaitTimeInMinutes;
    let totalWaitMin = deployReadyWaitMin + terminationWaitMin + CODE_DEPLOY_WAIT_BUFFER_MINUTES;
    if (totalWaitMin > CODE_DEPLOY_MAX_WAIT_MINUTES) {
      totalWaitMin = CODE_DEPLOY_MAX_WAIT_MINUTES;
    }
    if (totalWaitMin < CODE_DEPLOY_MIN_WAIT_MINUTES) {
      totalWaitMin = CODE_DEPLOY_MIN_WAIT_MINUTES;
    }
    const maxAttempts = (totalWaitMin * 60) / CODE_DEPLOY_WAIT_DEFAULT_DELAY_SEC;

    core.debug(`Waiting for the deployment to complete. Will wait for ${totalWaitMin} minutes`);
github cli / cli / .github / actions / build-msi / index.js View on Github external
const binPath = path.join(cwd, 'bin');
  fs.mkdirSync(binPath);
  console.log(`moving ${exePath} to bin/gh.exe`);
  fs.renameSync(exePath, path.join(binPath, 'gh.exe'));

  const msiPath = path.join(cwd, path.basename(exePath, '.exe') + '.msi');

  try {
    await exec.exec(
      '"C:\\Program Files\\go-msi\\go-msi.exe"',
      ['make',
       '--msi', msiPath,
       '--out', buildPath,
       '--version', version]);
    console.log(`build MSI at ${msiPath}`);
    core.setOutput('msi', msiPath);
  } catch(e) {
    core.setFailed(e.message);
  }
}
github mathieudutour / github-tag-action / src / main.ts View on Github external
const preRelease = releaseBranches
      .split(",")
      .every(branch => !GITHUB_REF.replace("refs/heads/", "").match(branch));

    const hasTag = !!(await exec("git tag")).stdout.trim();
    let tag = "";

    if (hasTag) {
      const previousTagSha = (
        await exec("git rev-list --tags --max-count=1")
      ).stdout.trim();
      tag = (await exec(`git describe --tags ${previousTagSha}`)).stdout.trim();

      if (previousTagSha === GITHUB_SHA) {
        core.debug("No new commits since previous tag. Skipping...");
        core.setOutput("previous_tag", tag);
        return;
      }
    } else {
      tag = "0.0.0";
      core.setOutput("previous_tag", tag);
    }

    const newTag = `${tagPrefix}${semver.inc(tag, bump)}${
      preRelease ? `-${GITHUB_SHA.slice(0, 7)}` : ""
    }`;

    core.setOutput("new_tag", newTag);

    core.debug(`New tag: ${newTag}`);

    if (preRelease) {
github r0adkll / sign-android-release / src / main.ts View on Github external
const releaseFilePath = path.join(releaseDir, releaseFile.name);
      let signedReleaseFile = '';
      if (releaseFile.name.endsWith('.apk')) {
        signedReleaseFile = await signApkFile(releaseFilePath, signingKey, alias, keyStorePassword, keyPassword);
      } else if (releaseFile.name.endsWith('.aab')) {
        signedReleaseFile = await signAabFile(releaseFilePath, signingKey, alias, keyStorePassword, keyPassword);
      } else {
        core.error('No valid release file to sign, abort.');
        core.setFailed('No valid release file to sign.');
      }

      console.log('Release signed!');
      core.debug('Release signed! Setting outputs');

      core.exportVariable("SIGNED_RELEASE_FILE", signedReleaseFile);
      core.setOutput('signedReleaseFile', signedReleaseFile);
    } else {
      core.error("No release file (.apk or .aab) could be found. Abort.");
      core.setFailed('No release file (.apk or .aab) could be found.');
    }
  } catch (error) {
    core.setFailed(error.message);
  }
}
github actions / cache / src / utils / actionUtils.ts View on Github external
export function setCacheHitOutput(isCacheHit: boolean): void {
    core.setOutput(Outputs.CacheHit, isCacheHit.toString());
}
github actions-rs / components-nightly / src / main.ts View on Github external
async function run() {
    core.warning('This Action is deprecated, see https://github.com/actions-rs/components-nightly#deprecation-notice');
    const opts = args.components_args();

    const date = await get(opts.target, opts.component);
    const toolchain = `nightly-${date}-${opts.target}`;
    const cargoCommand = COMPONENT_COMMANDS.get(opts.component) || opts.component;

    core.setOutput('toolchain', toolchain);
    core.setOutput('command', cargoCommand);
}
github mathieudutour / github-tag-action / src / main.ts View on Github external
let tag = "";

    if (hasTag) {
      const previousTagSha = (
        await exec("git rev-list --tags --max-count=1")
      ).stdout.trim();
      tag = (await exec(`git describe --tags ${previousTagSha}`)).stdout.trim();

      if (previousTagSha === GITHUB_SHA) {
        core.debug("No new commits since previous tag. Skipping...");
        core.setOutput("previous_tag", tag);
        return;
      }
    } else {
      tag = "0.0.0";
      core.setOutput("previous_tag", tag);
    }

    const newTag = `${tagPrefix}${semver.inc(tag, bump)}${
      preRelease ? `-${GITHUB_SHA.slice(0, 7)}` : ""
    }`;

    core.setOutput("new_tag", newTag);

    core.debug(`New tag: ${newTag}`);

    if (preRelease) {
      core.debug(
        "This branch is not a release branch. Skipping the tag creation."
      );
      return;
    }
github Flexget / webui / .github / actions / skip-deployment / index.js View on Github external
try {
    const { data } = await checks.listSuitesForRef({
      ...repo,
      ref,
    });
    const check = data.check_suites.find((s) => (
      s.app.slug === 'github-actions' && s.status === 'completed'
    ));
    if (!check || check.conclusion !== 'success') {
      setOutput('skip', 'true');
      setFailed(`Skipping deployment because tests failed to pass`);
      return;
    }

    info('Not skipping deployment');
    setOutput('skip', 'false');

  } catch(err) {
    setFailed(`Action failed with error ${err}`);
  }
}
github twilio-labs / actions-sms / dist / main.js View on Github external
async function run() {
    const from = core.getInput('fromPhoneNumber');
    const to = core.getInput('toPhoneNumber');
    const message = core.getInput('message');
    const accountSid = core.getInput('TWILIO_ACCOUNT_SID') || process.env.TWILIO_ACCOUNT_SID;
    const apiKey = core.getInput('TWILIO_API_KEY') || process.env.TWILIO_API_KEY;
    const apiSecret = core.getInput('TWILIO_API_SECRET') || process.env.TWILIO_API_SECRET;
    core.debug('Sending SMS');
    const client = twilio(apiKey, apiSecret, { accountSid });
    const resultMessage = await client.messages.create({
        from,
        to,
        body: message,
    });
    core.debug('SMS sent!');
    core.setOutput('messageSid', resultMessage.sid);
    return resultMessage;
}
async function execute() {