Skip to content

Commit

Permalink
added numberOfReviewers
Browse files Browse the repository at this point in the history
  • Loading branch information
Johanna Ahlskog committed Sep 14, 2023
1 parent 24bb011 commit 4dbd051
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/branchprotection/BranchProtectionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,26 @@ import * as github from '@actions/github';
export class BranchProtectionService {
public static async getStateOfBranchProtection(): Promise<void> {
console.log('\n Running branch protection control');
const token = core.getInput('repo-token');
//console.log('Got the token');

//numberOfReviewers > 0, if state of branch protection changes
let numberOfReviewers: number = 0;

const token = core.getInput('repo-token');
const octokit = github.getOctokit(token);
//console.log('octoKit authenticated');

const { owner, repo } = github.context.repo;
//console.log(`Owner: ${owner}`);
//console.log(`Repo: ${repo}`);

//console.log('Going to get branch protection');
await octokit.rest.repos
.getBranchProtection({
owner: owner,
repo: repo,
branch: 'main',
})
.then((response) => {
//console.log('Got the branch protection');
console.log(response.data);
})
.catch((error) => {
console.log('Branch protections is not enabled for repository: ' + repo)
//core.warning('Error getting branch protection!');
//console.log('Error: ', error.message);
});
core.exportVariable('numberOfReviewers', numberOfReviewers)
}
}

0 comments on commit 4dbd051

Please sign in to comment.