export async function getWorkflowFilePath()

in src/utilities/githubUtils.ts [4:34]


export async function getWorkflowFilePath(
   githubToken: string
): Promise<string> {
   let workflowFilePath = process.env.GITHUB_WORKFLOW
   if (!workflowFilePath.startsWith('.github/workflows/')) {
      const githubClient = new GitHubClient(
         process.env.GITHUB_REPOSITORY,
         githubToken
      )
      const response = await githubClient.getWorkflows()
      if (response) {
         if (response.status === OkStatusCode && response.data.total_count) {
            if (response.data.total_count > 0) {
               for (const workflow of response.data.workflows) {
                  if (process.env.GITHUB_WORKFLOW === workflow.name) {
                     workflowFilePath = workflow.path
                     break
                  }
               }
            }
         } else if (response.status != OkStatusCode) {
            core.error(
               `An error occurred while getting list of workflows on the repo. Status code: ${response.status}`
            )
         }
      } else {
         core.error(`Failed to get response from workflow list API`)
      }
   }
   return Promise.resolve(workflowFilePath)
}