Compare commits

..

4 Commits

Author SHA1 Message Date
Vidya Reddy ce6bc40bc4 added regex to check whitespace 2022-08-06 10:25:18 +05:30
Vidya Reddy 36041268eb fixes 2022-08-04 15:45:13 +05:30
Vidya Reddy 36b55e389b fixes 2022-07-29 17:58:29 +05:30
Vidya Reddy 6e560d48e7 Fixes to the docker with no images 2022-07-28 19:54:59 +05:30
4 changed files with 47 additions and 7 deletions
+1 -1
View File
@@ -143,7 +143,7 @@ export async function annotateAndLabelResources(
const workflowFilePath = await getWorkflowFilePath(githubToken)
const deploymentConfig = await getDeploymentConfig()
const annotationKeyLabel = getWorkflowAnnotationKeyLabel()
const annotationKeyLabel = getWorkflowAnnotationKeyLabel(workflowFilePath)
await annotateResources(
files,
+6 -1
View File
@@ -23,7 +23,12 @@ export async function getDeploymentConfig(): Promise<DeploymentConfig> {
)
}
const imageNames = core.getInput('images').split('\n') || []
let imageNames = core.getInput('images').split('\n') || []
imageNames.forEach((element) => {
if (element === null || '/^s+$/') {
imageNames.pop()
}
})
const imageDockerfilePathMap: {[id: string]: string} = {}
const pullImages = !(core.getInput('pull-images').toLowerCase() === 'false')
+19 -1
View File
@@ -1,6 +1,24 @@
import {cleanLabel} from '../utilities/workflowAnnotationUtils'
import {
cleanLabel,
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)
})
})
describe('cleanLabel', () => {
it('should clean label', () => {
const alreadyClean = 'alreadyClean'
+21 -4
View File
@@ -1,6 +1,13 @@
import {DeploymentConfig} from '../types/deploymentConfig'
const ANNOTATION_PREFIX = 'actions.github.com'
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,
@@ -24,11 +31,21 @@ 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(): string {
return `${ANNOTATION_PREFIX}/k8s-deploy`
export function getWorkflowAnnotationKeyLabel(
workflowFilePath: string
): string {
const hashKey = require('crypto')
.createHash('MD5')
.update(`${process.env.GITHUB_REPOSITORY}/${workflowFilePath}`)
.digest('hex')
return `githubWorkflow_${hashKey}`
}
/**