Skip to content

Commit

Permalink
add review-assigner.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
BBBmau committed Jun 13, 2024
1 parent 55edec5 commit 28c2d53
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/review-assigner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Reviewer Assigner"

on:
pull_request:
types: [opened]
issues:
types: [opened]

permissions:
pull-requests: 'write'

jobs:
assign-reviewer:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
- run: npm install @pagerduty/pdjs
- uses: actions/github-script@e69ef5462fd455e02edcaf4dd7708eda96b9eda0 # v7.0.0
env:
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 = ""
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: 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)
}
}

0 comments on commit 28c2d53

Please sign in to comment.