Skip to content

Commit

Permalink
try to get issue assigner working again
Browse files Browse the repository at this point in the history
  • Loading branch information
BBBmau committed Jun 13, 2024
1 parent 17400d2 commit d4c9be7
Showing 1 changed file with 21 additions and 32 deletions.
53 changes: 21 additions & 32 deletions .github/workflows/review-assigner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,36 @@ jobs:
PAGERDUTY_TOKEN: ${{ secrets.PAGERDUTY_TOKEN }}
with:
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});
const reviewer = ""
//const { PAGERDUTY_TOKEN } = process.env
//const { api } = require('@pagerduty/pdjs');
//const pd = api({token: PAGERDUTY_TOKEN});
//pd.get('/schedules/PG3X8HK/users')
// .then(({response}) => {
// console.log(response);
// }).catch(console.error)
console.log(context.issue.number)
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: ["BBBmau"], // 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: ["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)
//# }
//# }
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 d4c9be7

Please sign in to comment.