async function pushCoverage()

in src/reporter/coverage.ts [95:124]


async function pushCoverage(
  repo: string,
  ref: string,
  azStorageAccount: string,
  azStorageAccessKey: string,
  comment: string,
  version?: string,
) {
  if (!version) {
    version = getPublishedPackageVersion();
  }

  const blobSvc = new BlobServiceClient(
    `https://${azStorageAccount}.blob.core.windows.net`,
    new StorageSharedKeyCredential(azStorageAccount, azStorageAccessKey),
  );
  const containerClient = blobSvc.getContainerClient(`autorest-ci-coverage-report`);
  await containerClient.createIfNotExists({
    access: "blob",
  });

  const blockBlobClient = containerClient.getBlockBlobClient(`${repo.split("/")[1]}_${version}.md`);

  const content = `<!-- Ref: ${ref}, Generated at ${new Date().toISOString()} -->\n` + comment;
  blockBlobClient.upload(content, content.length, {
    blobHTTPHeaders: {
      blobContentType: "text/markdown; charset=utf-8",
    },
  });
}