export async function getLastSuccessfulRunSha()

in src/utilities/kubectlUtils.ts [29:57]


export async function getLastSuccessfulRunSha(
   kubectl: Kubectl,
   namespaceName: string,
   annotationKey: string
): Promise<string> {
   try {
      const result = await kubectl.getResource(
         NAMESPACE,
         namespaceName,
         false,
         namespaceName
      )
      if (result?.stderr) {
         core.warning(result.stderr)
         return process.env.GITHUB_SHA
      } else if (result?.stdout) {
         const annotationsSet = JSON.parse(result.stdout).metadata.annotations
         if (annotationsSet && annotationsSet[annotationKey]) {
            return JSON.parse(annotationsSet[annotationKey].replace(/'/g, '"'))
               .commit
         } else {
            return 'NA'
         }
      }
   } catch (ex) {
      core.warning(`Failed to get commits from cluster. ${JSON.stringify(ex)}`)
      return ''
   }
}