@graphql-inspector/action
Version:
GraphQL Inspector functionality for GitHub Actions
41 lines (40 loc) • 1.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateCheckRun = void 0;
const tslib_1 = require("tslib");
const core = tslib_1.__importStar(require("@actions/core"));
const github = tslib_1.__importStar(require("@actions/github"));
const github_1 = require("@graphql-inspector/github");
const utils_js_1 = require("./utils.js");
function updateCheckRun(octokit, checkId, { conclusion, output }) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
core.info(`Updating check: ${checkId}`);
const { title, summary, annotations = [] } = output;
const batches = (0, utils_js_1.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) => tslib_1.__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 === github_1.CheckConclusion.Failure) {
return core.setFailed(output.title);
}
// Success or Neutral
});
}
exports.updateCheckRun = updateCheckRun;