UNPKG

@graphql-inspector/action

Version:

GraphQL Inspector functionality for GitHub Actions

37 lines (36 loc) 1.6 kB
import { __awaiter } from "tslib"; import * as core from '@actions/core'; import * as github from '@actions/github'; import { CheckConclusion } from '@graphql-inspector/github'; import { batch } from './utils.js'; export function updateCheckRun(octokit, checkId, { conclusion, output }) { return __awaiter(this, void 0, void 0, function* () { core.info(`Updating check: ${checkId}`); const { title, summary, annotations = [] } = output; const batches = batch(annotations, 50); core.info(`annotations to be sent: ${annotations.length}`); yield octokit.checks.update(Object.assign(Object.assign({ check_run_id: checkId, completed_at: new Date().toISOString(), status: 'completed' }, github.context.repo), { conclusion, output: { title, summary, } })); try { yield Promise.all(batches.map((chunk) => __awaiter(this, void 0, void 0, function* () { yield octokit.checks.update(Object.assign(Object.assign({ check_run_id: checkId }, github.context.repo), { output: { title, summary, annotations: chunk, } })); core.info(`annotations sent (${chunk.length})`); }))); } catch (error) { core.error(`failed to send annotations: ${error}`); throw error; } // Fail if (conclusion === CheckConclusion.Failure) { return core.setFailed(output.title); } // Success or Neutral }); }