fix(scaffolder): added some logging if we can't enable branch protection for free repos
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -233,6 +233,7 @@ export function createPublishGithubAction(options: {
|
||||
owner,
|
||||
client,
|
||||
repoName: newRepo.name,
|
||||
logger: ctx.logger,
|
||||
});
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
|
||||
@@ -109,6 +109,7 @@ export class GithubPublisher implements PublisherBase {
|
||||
owner,
|
||||
client,
|
||||
repoName: name,
|
||||
logger,
|
||||
});
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to add branch protection to '${name}', ${e}`);
|
||||
|
||||
@@ -73,12 +73,14 @@ type BranchProtectionOptions = {
|
||||
client: Octokit;
|
||||
owner: string;
|
||||
repoName: string;
|
||||
logger: Logger;
|
||||
};
|
||||
|
||||
export const enableBranchProtectionOnDefaultRepoBranch = async ({
|
||||
repoName,
|
||||
client,
|
||||
owner,
|
||||
logger,
|
||||
}: BranchProtectionOptions): Promise<void> => {
|
||||
const tryOnce = () => {
|
||||
return client.repos.updateBranchProtection({
|
||||
@@ -105,6 +107,17 @@ export const enableBranchProtectionOnDefaultRepoBranch = async ({
|
||||
try {
|
||||
await tryOnce();
|
||||
} catch (e) {
|
||||
if (
|
||||
e.message.includes(
|
||||
'Upgrade to GitHub Pro or make this repository public to enable this feature',
|
||||
)
|
||||
) {
|
||||
logger.warn(
|
||||
'Branch protection was not enabled as it requires GitHub Pro for private repositories',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!e.message.includes('Branch not found')) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user