Permalink
Cannot retrieve contributors at this time
77 lines (77 sloc)
3.44 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/lib/upload-sarif-action.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | |
if (k2 === undefined) k2 = k; | |
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | |
}) : (function(o, m, k, k2) { | |
if (k2 === undefined) k2 = k; | |
o[k2] = m[k]; | |
})); | |
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | |
Object.defineProperty(o, "default", { enumerable: true, value: v }); | |
}) : function(o, v) { | |
o["default"] = v; | |
}); | |
var __importStar = (this && this.__importStar) || function (mod) { | |
if (mod && mod.__esModule) return mod; | |
var result = {}; | |
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | |
__setModuleDefault(result, mod); | |
return result; | |
}; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
const core = __importStar(require("@actions/core")); | |
const actionsUtil = __importStar(require("./actions-util")); | |
const api_client_1 = require("./api-client"); | |
const logging_1 = require("./logging"); | |
const repository_1 = require("./repository"); | |
const upload_lib = __importStar(require("./upload-lib")); | |
const util_1 = require("./util"); | |
// eslint-disable-next-line import/no-commonjs | |
const pkg = require("../package.json"); | |
async function sendSuccessStatusReport(startedAt, uploadStats) { | |
const statusReportBase = await actionsUtil.createStatusReportBase("upload-sarif", "success", startedAt); | |
const statusReport = { | |
...statusReportBase, | |
...uploadStats, | |
}; | |
await actionsUtil.sendStatusReport(statusReport); | |
} | |
async function run() { | |
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version); | |
const startedAt = new Date(); | |
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("upload-sarif", "starting", startedAt)))) { | |
return; | |
} | |
try { | |
const apiDetails = { | |
auth: actionsUtil.getRequiredInput("token"), | |
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"), | |
}; | |
const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)(); | |
const uploadResult = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, (0, logging_1.getActionsLogger)()); | |
core.setOutput("sarif-id", uploadResult.sarifID); | |
if (actionsUtil.getRequiredInput("wait-for-processing") === "true") { | |
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)()); | |
} | |
await sendSuccessStatusReport(startedAt, uploadResult.statusReport); | |
} | |
catch (error) { | |
const message = error instanceof Error ? error.message : String(error); | |
const stack = error instanceof Error ? error.stack : String(error); | |
core.setFailed(message); | |
console.log(error); | |
await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("upload-sarif", actionsUtil.getActionsStatus(error), startedAt, message, stack)); | |
return; | |
} | |
} | |
async function runWrapper() { | |
try { | |
await run(); | |
} | |
catch (error) { | |
core.setFailed(`codeql/upload-sarif action failed: ${error}`); | |
console.log(error); | |
} | |
} | |
void runWrapper(); | |
//# sourceMappingURL=upload-sarif-action.js.map |