How to use the @actions/core.setFailed 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 mathieudutour / github-tag-action / src / main.ts View on Github external
async function run() {
  try {
    // @ts-ignore
    const bump: ReleaseType = core.getInput("default_bump");
    const tagPrefix = core.getInput("tag_prefix");
    const releaseBranches = core.getInput("release_branches");

    const { GITHUB_REF, GITHUB_SHA } = process.env;

    if (!GITHUB_REF) {
      core.setFailed("Missing GITHUB_REF");
      return;
    }

    if (!GITHUB_SHA) {
      core.setFailed("Missing GITHUB_SHA");
      return;
    }

    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();
github mooyoul / tslint-actions / index.ts View on Github external
})().catch((e) => {
  console.error(e.stack); // tslint:disable-line
  core.setFailed(e.message);
});
github h5bp / server-configs-test / index.js View on Github external
uts.filter(name => core.getInput(name) && core.getInput(name) !== 'false')

    core.debug(uts.join(':'))

    if (uts.includes('version')) {
      uts.splice(uts.indexOf('version'), 1)
      await execute(['version'])
      return
    }
    if (uts.length === 0) {
      return
    }

    await execute(['run', 'lib/index.js', '-e', `TESTS=${uts.join(':')}`])
  } catch (error) {
    core.setFailed(error.message)
  }
}
github goto-bus-stop / standard-action / index.js View on Github external
const linter = loadLinter(linterName)

  const lintFiles = promisify(linter.lintFiles.bind(linter))
  const results = await lintFiles(files || [], {
    cwd: GITHUB_WORKSPACE
  })

  printResults(results, formatStyle)

  if (useAnnotations === 'true') {
    try {
      await publishResults(results)
    } catch (err) {
      console.error(err)
      actions.setFailed(err.message)
    }
  }

  if (results.errorCount > 0) {
    actions.setFailed(`${results.errorCount} error(s), ${results.warningCount} warning(s) found`)
    process.exit(1)
  }
}
github r0adkll / sign-android-release / src / main.ts View on Github external
} 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 peter-evans / slash-command-dispatch / src / func.js View on Github external
function configIsValid(config) {
  for (const command of config) {
    if (!["none", "read", "write", "admin"].includes(command.permission)) {
      core.setFailed(`'${command.permission}' is not a valid 'permission'.`);
      return false;
    }
    if (!["issue", "pull-request", "both"].includes(command.issue_type)) {
      core.setFailed(`'${command.issue_type}' is not a valid 'issue-type'.`);
      return false;
    }
  }
  return true;
}
github sparkfabrik / ios-build-action / index.js View on Github external
process.env.TEAM_ID = core.getInput("team-id");
    process.env.WORKSPACE_PATH = core.getInput("workspace-path");
    process.env.EXPORT_METHOD = core.getInput("export-method");
    process.env.CONFIGURATION = core.getInput("configuration");
    process.env.CERTIFICATE_PASSWORD = core.getInput("certificate-password");
    process.env.OUTPUT_PATH = core.getInput("output-path");
    process.env.SCHEME = core.getInput("scheme");
    process.env.DISABLE_TARGETS = core.getInput("disable-targets");
    process.env.BROWSERSTACK_UPLOAD = core.getInput("browserstack-upload");
    process.env.BROWSERSTACK_USERNAME = core.getInput("browserstack-username");
    process.env.BROWSERSTACK_ACCESS_KEY = core.getInput("browserstack-access-key");
    process.env.BUILD_PODS = core.getInput("build-pods");
    process.env.PODS_PATH = core.getInput("pods-path");
    await exec.exec(`bash ${__dirname}/../build.sh`);
  } catch (error) {
    core.setFailed(error.message);
  }
}
github cemkiy / action-slacker / index.js View on Github external
{
          "title": `${process.env.GITHUB_REPOSITORY}`,
          "title_link": `https://github.com/${process.env.GITHUB_REPOSITORY}`,
          "color": attachment.color,
          "text": `${process.env.GITHUB_REF}`,
          "author_name": `${process.env.GITHUB_ACTOR}`,
    			"author_link": `https://github.com/${process.env.GITHUB_ACTOR}`,
    			"author_icon": `https://github.com/${process.env.GITHUB_ACTOR}.png`,
          "footer": `action -> ${process.env.GITHUB_EVENT_NAME}`,
          "thumb_url":"https://avatars0.githubusercontent.com/u/44036562?s=200&v=4"
        },
        attachment
      ]
    });
  } catch (error) {
    core.setFailed(error.message);
  }
}
github actions / cache / src / restore.ts View on Github external
const isExactKeyMatch = utils.isExactKeyMatch(
                primaryKey,
                cacheEntry
            );
            utils.setCacheHitOutput(isExactKeyMatch);

            core.info(
                `Cache restored from key: ${cacheEntry && cacheEntry.cacheKey}`
            );
        } catch (error) {
            core.warning(error.message);
            utils.setCacheHitOutput(false);
        }
    } catch (error) {
        core.setFailed(error.message);
    }
}
github peaceiris / actions-hugo / src / index.ts View on Github external
function(error) {
          core.setFailed(error);
        }
      );