From 2ead81063dd2730353001ddaac77a2cd6c57cca3 Mon Sep 17 00:00:00 2001 From: hampus-andersson-op Date: Fri, 10 May 2024 15:19:38 +0200 Subject: [PATCH 1/2] Set number of reviewers to 0 When repo is private and using GitHub free --- src/branchprotection/BranchProtectionService.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/branchprotection/BranchProtectionService.ts b/src/branchprotection/BranchProtectionService.ts index 0be2ad68..c102fd48 100644 --- a/src/branchprotection/BranchProtectionService.ts +++ b/src/branchprotection/BranchProtectionService.ts @@ -49,10 +49,18 @@ export class BranchProtectionService { }); } } else { - core.info('Failed to get branch protection'); - core.notice(errorMessage, { - title: 'Branch protection control failed', - }); + switch (errorMessage) { + case 'Upgrade to GitHub Pro or make this repository public to enable this feature.': + core.exportVariable('numberOfReviewers', 0); + break; + + default: + core.info('Failed to get branch protection'); + core.notice(errorMessage, { + title: 'Branch protection control failed', + }); + break; + } } } console.log(); From ea24c797d686b4f3834116c89f1a3631a8c4e2d3 Mon Sep 17 00:00:00 2001 From: hampus-andersson-op Date: Fri, 10 May 2024 15:26:10 +0200 Subject: [PATCH 2/2] Add error log --- src/branchprotection/BranchProtectionService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/branchprotection/BranchProtectionService.ts b/src/branchprotection/BranchProtectionService.ts index c102fd48..4d143855 100644 --- a/src/branchprotection/BranchProtectionService.ts +++ b/src/branchprotection/BranchProtectionService.ts @@ -51,6 +51,7 @@ export class BranchProtectionService { } else { switch (errorMessage) { case 'Upgrade to GitHub Pro or make this repository public to enable this feature.': + console.log('Branch protection is not enabled for repository:', repo); core.exportVariable('numberOfReviewers', 0); break;