diff --git a/src/utilities/workflowAnnotationUtils.test.ts b/src/utilities/workflowAnnotationUtils.test.ts new file mode 100644 index 000000000..0a467686e --- /dev/null +++ b/src/utilities/workflowAnnotationUtils.test.ts @@ -0,0 +1,18 @@ +import { prefixObjectKeys } from "../utilities/workflowAnnotationUtils"; + +describe("WorkflowAnnotationUtils", () => { + describe("prefixObjectKeys", () => { + it("should prefix an object with a given prefix", () => { + const obj = { + foo: "bar", + baz: "qux", + }; + const prefix = "prefix."; + const expected = { + "prefix.foo": "bar", + "prefix.baz": "qux", + }; + expect(prefixObjectKeys(obj, prefix)).toEqual(expected); + }); + }); +}); \ No newline at end of file diff --git a/src/utilities/workflowAnnotationUtils.ts b/src/utilities/workflowAnnotationUtils.ts index b99f4a99f..5e95fdb41 100644 --- a/src/utilities/workflowAnnotationUtils.ts +++ b/src/utilities/workflowAnnotationUtils.ts @@ -1,5 +1,14 @@ import { DeploymentConfig } from "../types/deploymentConfig"; +const ANNOTATION_PREFIX = "actions.github.com/"; + +export function prefixObjectKeys(obj: any, prefix: string): any { + return Object.keys(obj).reduce((newObj, key) => { + newObj[prefix + key] = obj[key]; + return newObj; + }, {}); +} + export function getWorkflowAnnotations( lastSuccessRunSha: string, workflowFilePath: string, @@ -22,7 +31,8 @@ export function getWorkflowAnnotations( helmChartPaths: deploymentConfig.helmChartFilePaths, provider: "GitHub", }; - return JSON.stringify(annotationObject); + const prefixedAnnotationObject = prefixObjectKeys(annotationObject, ANNOTATION_PREFIX); + return JSON.stringify(prefixedAnnotationObject); } export function getWorkflowAnnotationKeyLabel(