Skip to content

Commit

Permalink
add pagerduty
Browse files Browse the repository at this point in the history
  • Loading branch information
BBBmau committed Jun 13, 2024
1 parent efbb5c5 commit be56fe6
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions .github/workflows/review-assigner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,45 @@ jobs:
script: |
const { PAGERDUTY_TOKEN } = process.env
const { api } = require('@pagerduty/pdjs');
const reviewerList = new Map([
["Sheneska Williams", "sheneska"],
["Mauricio Alvarez Leon", "BBBmau"],
["Alex Somesan", "alexsomesan"],
["Alex Pilon", "appilon"],
["John Houston", "jrhouston"],
["Aleksandr Rybolovlev", "arybolovlev"],
]);
const pd = api({token: PAGERDUTY_TOKEN});
pd.get('/schedules/id/users')
.then((response) => {
console.log("Assigning to " + response.users);
}).catch(console.error)
const reviewer = ""
console.log("triggered by: " + context.eventName)
pd.get('oncalls?escalation_policy_ids%5B%5D=PH8IF3M')
.then(({data}) => {
reviewer = data.oncalls[0].user.summary
console.log("Assigning issue to " + data.oncalls[0].user.summary);
}).catch(console.error)
if (context.eventName == "issues"){
try{
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
assignees: ["BBBmau"], // this will be replaced with pagerduty resp
assignees: reviewerList.get(reviewer), // this will be replaced with pagerduty resp
issue_number: context.issue.number, // issue.number is used for both issues and PRs
})
} catch(error){
core.setFailed("error assigning assignee:" + error)
}
}
if (context.eventName == "pull_request"){
try{
await github.rest.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
reviewers: ["BBBmau"], // this will be replaced with pagerduty resp
pull_number: (context.issue.number - 1), // for some reason we get PR+1 from context
})
} catch(error){
core.setFailed("error assigning reviewer:" + error)
}
}
//# if (context.eventName == "pull_request"){
//# try{
//# await github.rest.pulls.requestReviewers({
//# owner: context.repo.owner,
//# repo: context.repo.repo,
//# reviewers: ["sheneska"], // this will be replaced with pagerduty resp
//# pull_number: context.issue.number, // for some reason we get PR+1 from context
//# })
//# } catch(error){
//# core.setFailed("error assigning reviewer:" + error)
//# }
//# }

0 comments on commit be56fe6

Please sign in to comment.