-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf57b06
commit 03a43f3
Showing
2 changed files
with
33 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as core from '@actions/core'; | ||
import * as github from '@actions/github'; | ||
export class BranchProtectionService{ | ||
|
||
public static async getStateOfBranchProtection(): Promise<void> { | ||
console.log('Custom task is working!'); | ||
const token = core.getInput('repo-token'); | ||
console.log("Got the 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) => { | ||
core.warning("Error getting branch protection!"); | ||
core.warning("Error: ", error.message); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters