diff --git a/lib/constants.js b/lib/constants.js index 2bfa414c..3dd2be68 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -26,23 +26,22 @@ exports.deploymentTypes = ['deployment', 'replicaset', 'daemonset', 'pod', 'stat exports.workloadTypes = ['deployment', 'replicaset', 'daemonset', 'pod', 'statefulset', 'job', 'cronjob']; exports.workloadTypesWithRolloutStatus = ['deployment', 'daemonset', 'statefulset']; function getWorkflowAnnotationsJson(lastSuccessRunSha, workflowFilePath, filePathConfigs) { - return `{` - + `'run': '${process.env.GITHUB_RUN_ID}',` - + `'repository': '${process.env.GITHUB_REPOSITORY}',` - + `'workflow': '${process.env.GITHUB_WORKFLOW}',` - + `'workflowFileName': '${workflowFilePath.replace(".github/workflows/", "")}',` - + `'jobName': '${process.env.GITHUB_JOB}',` - + `'createdBy': '${process.env.GITHUB_ACTOR}',` - + `'runUri': 'https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}',` - + `'commit': '${process.env.GITHUB_SHA}',` - + `'lastSuccessRunCommit': '${lastSuccessRunSha}',` - + `'branch': '${process.env.GITHUB_REF}',` - + `'deployTimestamp': '${Date.now()}',` - + `'dockerfilePaths': '${JSON.stringify(filePathConfigs.dockerfilePaths, null, 2)}',` - + `'manifestsPaths': '${JSON.stringify(filePathConfigs.manifestFilePaths, null, 2)}',` - + `'helmChartPaths': '${JSON.stringify(filePathConfigs.helmChartFilePaths, null, 2)}',` - + `'provider': 'GitHub'` - + `}`; + let annotationObject; + annotationObject["run"] = process.env.GITHUB_RUN_ID; + annotationObject["repository"] = process.env.GITHUB_REPOSITORY; + annotationObject["workflow"] = process.env.GITHUB_WORKFLOW; + annotationObject["workflowFileName"] = workflowFilePath.replace(".github/workflows/", ""); + annotationObject["jobName"] = process.env.GITHUB_JOB; + annotationObject["createdBy"] = process.env.GITHUB_ACTOR; + annotationObject["runUri"] = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; + annotationObject["commit"] = process.env.GITHUB_SHA; + annotationObject["branch"] = process.env.GITHUB_REF; + annotationObject["deployTimestamp"] = Date.now(); + annotationObject["dockerfilePaths"] = filePathConfigs.dockerfilePaths; + annotationObject["manifestsPaths"] = filePathConfigs.manifestFilePaths; + annotationObject["helmChartPaths"] = filePathConfigs.helmChartFilePaths; + annotationObject["provider"] = "GitHub"; + return JSON.stringify(annotationObject); } exports.getWorkflowAnnotationsJson = getWorkflowAnnotationsJson; function getWorkflowAnnotationKeyLabel(workflowFilePath) { diff --git a/lib/utilities/utility.js b/lib/utilities/utility.js index e4a4ed0d..9f3d3819 100644 --- a/lib/utilities/utility.js +++ b/lib/utilities/utility.js @@ -151,7 +151,7 @@ function getFilePathsConfigs() { let helmChartPaths = []; if (process.env.HELM_CHART_PATHS) { helmChartPaths = process.env.HELM_CHART_PATHS.split('\n'); - helmChartPaths.filter(val => val != ""); + helmChartPaths.splice(-1); } filePathsConfig[HELM_CHART_KEY] = helmChartPaths; //Fetch labels from each image diff --git a/src/constants.ts b/src/constants.ts index f7da49e2..6b96b36d 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -26,23 +26,23 @@ export const workloadTypes: string[] = ['deployment', 'replicaset', 'daemonset', export const workloadTypesWithRolloutStatus: string[] = ['deployment', 'daemonset', 'statefulset']; export function getWorkflowAnnotationsJson(lastSuccessRunSha: string, workflowFilePath: string, filePathConfigs: any): string { - return `{` - + `'run': '${process.env.GITHUB_RUN_ID}',` - + `'repository': '${process.env.GITHUB_REPOSITORY}',` - + `'workflow': '${process.env.GITHUB_WORKFLOW}',` - + `'workflowFileName': '${workflowFilePath.replace(".github/workflows/", "")}',` - + `'jobName': '${process.env.GITHUB_JOB}',` - + `'createdBy': '${process.env.GITHUB_ACTOR}',` - + `'runUri': 'https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}',` - + `'commit': '${process.env.GITHUB_SHA}',` - + `'lastSuccessRunCommit': '${lastSuccessRunSha}',` - + `'branch': '${process.env.GITHUB_REF}',` - + `'deployTimestamp': '${Date.now()}',` - + `'dockerfilePaths': '${JSON.stringify(filePathConfigs.dockerfilePaths,null,2)}',` - + `'manifestsPaths': '${JSON.stringify(filePathConfigs.manifestFilePaths,null,2)}',` - + `'helmChartPaths': '${JSON.stringify(filePathConfigs.helmChartFilePaths,null,2)}',` - + `'provider': 'GitHub'` - + `}`; + let annotationObject: any; + annotationObject["run"] = process.env.GITHUB_RUN_ID; + annotationObject["repository"] = process.env.GITHUB_REPOSITORY; + annotationObject["workflow"] = process.env.GITHUB_WORKFLOW; + annotationObject["workflowFileName"] = workflowFilePath.replace(".github/workflows/", ""); + annotationObject["jobName"] = process.env.GITHUB_JOB; + annotationObject["createdBy"] = process.env.GITHUB_ACTOR; + annotationObject["runUri"] = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; + annotationObject["commit"] = process.env.GITHUB_SHA; + annotationObject["branch"] = process.env.GITHUB_REF; + annotationObject["deployTimestamp"] = Date.now(); + annotationObject["dockerfilePaths"] = filePathConfigs.dockerfilePaths; + annotationObject["manifestsPaths"] = filePathConfigs.manifestFilePaths + annotationObject["helmChartPaths"] = filePathConfigs.helmChartFilePaths; + annotationObject["provider"] = "GitHub"; + + return JSON.stringify(annotationObject); } export function getWorkflowAnnotationKeyLabel(workflowFilePath: string): string { diff --git a/src/utilities/utility.ts b/src/utilities/utility.ts index 018cf646..c255af6e 100644 --- a/src/utilities/utility.ts +++ b/src/utilities/utility.ts @@ -144,7 +144,7 @@ export async function getFilePathsConfigs(): Promise { let helmChartPaths = []; if(process.env.HELM_CHART_PATHS){ helmChartPaths = process.env.HELM_CHART_PATHS.split('\n'); - helmChartPaths.filter( val => val != "" ); + helmChartPaths.splice(-1); } filePathsConfig[HELM_CHART_KEY] = helmChartPaths;