Merge pull request #34 from github/upload_ref
upload ref in status report
This commit is contained in:
commit
74c9991849
4 changed files with 23 additions and 2 deletions
2
lib/upload-lib.js
generated
2
lib/upload-lib.js
generated
|
|
@ -141,7 +141,7 @@ async function uploadFiles(sarifFiles) {
|
|||
}
|
||||
const commitOid = util.getRequiredEnvParam('GITHUB_SHA');
|
||||
const workflowRunIDStr = util.getRequiredEnvParam('GITHUB_RUN_ID');
|
||||
const ref = util.getRequiredEnvParam('GITHUB_REF'); // it's in the form "refs/heads/master"
|
||||
const ref = util.getRef();
|
||||
const analysisKey = await util.getAnalysisKey();
|
||||
const analysisName = util.getRequiredEnvParam('GITHUB_WORKFLOW');
|
||||
const startedAt = process.env[sharedEnv.CODEQL_ACTION_STARTED_AT];
|
||||
|
|
|
|||
10
lib/util.js
generated
10
lib/util.js
generated
|
|
@ -192,6 +192,14 @@ async function getAnalysisKey() {
|
|||
return analysisKey;
|
||||
}
|
||||
exports.getAnalysisKey = getAnalysisKey;
|
||||
/**
|
||||
* Get the ref currently being analyzed.
|
||||
*/
|
||||
function getRef() {
|
||||
// it's in the form "refs/heads/master"
|
||||
return getRequiredEnvParam('GITHUB_REF');
|
||||
}
|
||||
exports.getRef = getRef;
|
||||
/**
|
||||
* Compose a StatusReport.
|
||||
*
|
||||
|
|
@ -202,6 +210,7 @@ exports.getAnalysisKey = getAnalysisKey;
|
|||
*/
|
||||
async function createStatusReport(actionName, status, cause, exception) {
|
||||
const commitOid = process.env['GITHUB_SHA'] || '';
|
||||
const ref = getRef();
|
||||
const workflowRunIDStr = process.env['GITHUB_RUN_ID'];
|
||||
let workflowRunID = -1;
|
||||
if (workflowRunIDStr) {
|
||||
|
|
@ -218,6 +227,7 @@ async function createStatusReport(actionName, status, cause, exception) {
|
|||
job_name: jobName,
|
||||
languages: languages,
|
||||
commit_oid: commitOid,
|
||||
ref: ref,
|
||||
action_name: actionName,
|
||||
action_oid: "unknown",
|
||||
started_at: startedAt,
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ async function uploadFiles(sarifFiles: string[]): Promise<boolean> {
|
|||
|
||||
const commitOid = util.getRequiredEnvParam('GITHUB_SHA');
|
||||
const workflowRunIDStr = util.getRequiredEnvParam('GITHUB_RUN_ID');
|
||||
const ref = util.getRequiredEnvParam('GITHUB_REF'); // it's in the form "refs/heads/master"
|
||||
const ref = util.getRef();
|
||||
const analysisKey = await util.getAnalysisKey();
|
||||
const analysisName = util.getRequiredEnvParam('GITHUB_WORKFLOW');
|
||||
const startedAt = process.env[sharedEnv.CODEQL_ACTION_STARTED_AT];
|
||||
|
|
|
|||
11
src/util.ts
11
src/util.ts
|
|
@ -200,6 +200,14 @@ export async function getAnalysisKey(): Promise<string> {
|
|||
return analysisKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ref currently being analyzed.
|
||||
*/
|
||||
export function getRef(): string {
|
||||
// it's in the form "refs/heads/master"
|
||||
return getRequiredEnvParam('GITHUB_REF');
|
||||
}
|
||||
|
||||
interface StatusReport {
|
||||
"workflow_run_id": number;
|
||||
"workflow_name": string;
|
||||
|
|
@ -207,6 +215,7 @@ interface StatusReport {
|
|||
"matrix_vars"?: string;
|
||||
"languages": string;
|
||||
"commit_oid": string;
|
||||
"ref": string;
|
||||
"action_name": string;
|
||||
"action_oid": string;
|
||||
"started_at": string;
|
||||
|
|
@ -232,6 +241,7 @@ async function createStatusReport(
|
|||
Promise<StatusReport> {
|
||||
|
||||
const commitOid = process.env['GITHUB_SHA'] || '';
|
||||
const ref = getRef();
|
||||
const workflowRunIDStr = process.env['GITHUB_RUN_ID'];
|
||||
let workflowRunID = -1;
|
||||
if (workflowRunIDStr) {
|
||||
|
|
@ -249,6 +259,7 @@ async function createStatusReport(
|
|||
job_name: jobName,
|
||||
languages: languages,
|
||||
commit_oid: commitOid,
|
||||
ref: ref,
|
||||
action_name: actionName,
|
||||
action_oid: "unknown", // TODO decide if it's possible to fill this in
|
||||
started_at: startedAt,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue