mirror of
https://github.com/github/codeql-action.git
synced 2025-12-26 17:20:10 +08:00
This PR ensures environment variables are set before any invocation of the CLI. Here is a list of vars that are set: https://github.com/github/codeql-coreql-team/issues/1124#issuecomment-852463521 This ensures the CLI knows the features and versions of the containing actions/runner. Additionally: - Fix the user agent so that it more closely aligns with user agent spec - Refactor environment variable initialization so that it all happens in one place and call. - Move Mode, getRequiredEnvParam, setMode, getMode out of actions-util and into util. actions-util is meant for utils only called by the action, not the runner. The `prepareLocalRunEnvironment()` method is most likely deprecated and should be removed. I originally added it because I had a way of working where I would run the action from my local machine to test out changes, but this was always a little flaky. So, I no longer use this way of working. I will probably remove it soon.
57 lines
2.2 KiB
JavaScript
Generated
57 lines
2.2 KiB
JavaScript
Generated
"use strict";
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
result["default"] = mod;
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const core = __importStar(require("@actions/core"));
|
|
const actionsUtil = __importStar(require("./actions-util"));
|
|
const logging_1 = require("./logging");
|
|
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() {
|
|
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: util_1.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
|
};
|
|
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
|
const uploadStats = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, logging_1.getActionsLogger());
|
|
await sendSuccessStatusReport(startedAt, uploadStats);
|
|
}
|
|
catch (error) {
|
|
core.setFailed(error.message);
|
|
console.log(error);
|
|
await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("upload-sarif", "failure", startedAt, error.message, error.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
|