message: Scaffolder: Enable branch protection on new repo
diff: */
  import { PublisherBase, PublisherOptions, PublisherResult } from './types';
  -import { initRepoAndPush } from './helpers';
  +import {
  + enableBranchProtectionOnDefaultRepoBranch,
  + initRepoAndPush,
  +} from './helpers';
  import {
  GitHubIntegrationConfig,
  GithubCredentialsProvider,
  @@ -99,6 +102,19 @@ export class GithubPublisher implements PublisherBase {
  /\.git$/,
  '/blob/master/catalog-info.yaml',
  );
  +
  + try {
  + await enableBranchProtectionOnDefaultRepoBranch({
  + owner,
  + client,
  + repoName: name,
  + });
  + } catch (e) {
  + throw new Error(
  + `Failed to add branch protection to '${name}': ${e.message}`,
  + );
  + }
  +
  return { remoteUrl, catalogInfoUrl };
  }
  @@ -130,7 +146,7 @@ export class GithubPublisher implements PublisherBase {
  description,
  });
  - const { data } = await repoCreationPromise;
  + const { data: newRepo } = await repoCreationPromise;
  try {
  if (access?.startsWith(`${owner}/`)) {
  @@ -156,6 +172,7 @@ export class GithubPublisher implements PublisherBase {
  `Failed to add access to '${access}'. Status ${e.status} ${e.message}`,
  );
  }
  - return data?.clone_url;
  +
  + return newRepo.clone_url;
  }
  }
  