diff --git a/.github/workflows/review-assigner.yaml b/.github/workflows/review-assigner.yaml index fabc9bdc93..eb7a596fcd 100644 --- a/.github/workflows/review-assigner.yaml +++ b/.github/workflows/review-assigner.yaml @@ -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) - //# } - //# } \ No newline at end of file + 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) + } + }