@jsenv/github-check-run

0.1.10 • Public • Published

GitHub check run npm package

import { startGithubCheckRun } from "@jsenv/github-check-run";

const values = [1_000, 2_000, 4_000];

const githubCheck = await startGithubCheckRun({
  githubToken: "",
  repositoryOwner: "dmail",
  repositoryName: "repo-name",
  commitSha: "",
  checkName: "demo",
  checkTitle: "Running demo",
  checkSummary: `preparing execution of ${values.length} timeouts`,
});

try {
  let index = 0;
  for (const value of values) {
    githubCheck.progress({
      summary: `executing timeout ${index + 1}/${values.length}`,
    });
    await new Promise((resolve) => {
      setTimeout(resolve, value);
    });
    index++;
  }
  await githubCheck.pass({
    summary: `${values.length} timeout execution done`,
  });
} catch (e) {
  await githubCheck.fail({
    summary: `error while executing timeout number ${index + 1}: ${e.stack}`,
  });
}

If the code is executed inside a Github workflow, several parameters can be retrieved using readGitHubWorkflowEnv:

import {
  startGithubCheckRun,
  readGitHubWorkflowEnv,
} from "@jsenv/github-check-run";

const githubCheck = await startGithubCheckRun({
  ...readGitHubWorkflowEnv(),
  checkName: "demo",
  checkTitle: "Running demo",
  checkSummary: `Executing ${values.length} setTimeouts`,
});

Readme

Keywords

none

Package Sidebar

Install

npm i @jsenv/github-check-run

Weekly Downloads

20

Version

0.1.10

License

MIT

Unpacked Size

12.8 kB

Total Files

6

Last publish

Collaborators

  • jsenv-admin
  • dmail