forked from hashicorp/terraform-provider-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |