Skip to content

Commit bb46733

Browse files
BBBmaualexsomesan
andauthored
add oncall_review_assigner step into issue-opened.yml workflow (#2513)
* initial review-assigner.yaml creation * base of setting assignees/reviewers * assigner/reviewer part done * set to reviewers * Update .github/workflows/review-assigner.yaml Co-authored-by: Alex Somesan <[email protected]> * include assigner in issue-opened.yml --------- Co-authored-by: Alex Somesan <[email protected]>
1 parent 481c432 commit bb46733

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/workflows/issue-opened.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,42 @@ jobs:
1414
repo-token: "${{ secrets.GITHUB_TOKEN }}"
1515
configuration-path: .github/labeler-issue-triage.yml
1616
enable-versioned-regex: 0
17+
oncall_review_assigner:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/setup-node@v4
21+
- run: npm install @pagerduty/pdjs
22+
- uses: actions/github-script@e69ef5462fd455e02edcaf4dd7708eda96b9eda0 # v7.0.0
23+
env:
24+
PAGERDUTY_TOKEN: ${{ secrets.PAGERDUTY_TOKEN }}
25+
with:
26+
script: |
27+
const { PAGERDUTY_TOKEN } = process.env
28+
const { api } = require('@pagerduty/pdjs');
29+
const pd = api({token: PAGERDUTY_TOKEN});
30+
let reviewer = ""
31+
const reviewerList = new Map([
32+
["Sheneska Williams", "sheneska"],
33+
["Mauricio Alvarez Leon", "BBBmau"],
34+
["Alex Somesan", "alexsomesan"],
35+
["Alex Pilon", "appilon"],
36+
["John Houston", "jrhouston"],
37+
["Aleksandr Rybolovlev", "arybolovlev"],
38+
]);
39+
40+
pd.get('oncalls?escalation_policy_ids%5B%5D=PH8IF3M')
41+
.then(({data}) => {
42+
reviewer = reviewerList.get(data.oncalls[0].user.summary)
43+
console.log("Assigning issue to " + reviewer);
44+
}).catch(console.error)
45+
46+
try{
47+
await github.rest.issues.addAssignees({
48+
owner: context.repo.owner,
49+
repo: context.repo.repo,
50+
assignees: reviewer,
51+
issue_number: context.issue.number,
52+
})
53+
} catch(error){
54+
core.setFailed("error assigning reviewer: " + error)
55+
}

0 commit comments

Comments
 (0)