-
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
cc9a938
commit 03961c6
Showing
1 changed file
with
24 additions
and
22 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 |
---|---|---|
@@ -1,30 +1,32 @@ | ||
import * as core from '@actions/core'; | ||
import * as github from '@actions/github'; | ||
export class BranchProtectionService{ | ||
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'); | ||
|
||
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 octokit = github.getOctokit(token); | ||
console.log("octoKit authenticated"); | ||
const { owner, repo } = github.context.repo; | ||
console.log(`Owner: ${owner}`); | ||
console.log(`Repo: ${repo}`); | ||
|
||
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({ | ||
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); | ||
}); | ||
} | ||
} | ||
}) | ||
.then((response) => { | ||
console.log('Got the branch protection'); | ||
console.log(response.data); | ||
}) | ||
.catch((error) => { | ||
core.warning('Error getting branch protection!'); | ||
console.log('Error: ', error); | ||
}); | ||
} | ||
} |