-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically add assignees to issues based on product labels (#6512)
* Automatically add assignee to issues with product labels * Some clean up * Assignee changes --------- Co-authored-by: keertk <keerthanakumar@google.com>
- Loading branch information
Showing
3 changed files
with
58 additions
and
8 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
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
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,58 @@ | ||
name: Auto-add assignees to issues | ||
on: | ||
issues: | ||
types: | ||
- reopened | ||
- opened | ||
jobs: | ||
add_label: | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/labeler@v4 | ||
add_assignee: | ||
runs-on: ubuntu-latest | ||
needs: add_label | ||
permissions: | ||
contents: read | ||
issues: write | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
- name: Set assignees | ||
uses: actions/github-script@v4 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
let issue_number = context.payload.issue.number; | ||
let issueDetails = await github.issues.get({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number, | ||
}); | ||
let labels = issueDetails.data.labels; | ||
const labelToAssignees = { | ||
'product: CLion': ['tpasternak'], | ||
'product: IntelliJ': ['mai93'], | ||
'product: GoLand': ['mai93'], | ||
'product: Android Studio': ['mai93'], | ||
'product: PyCharm': ['mai93'] | ||
}; | ||
const assignees = labels.some(label => label.name.startsWith('product:')) | ||
? labels.reduce((acc, label) => { | ||
const assignee = label.name in labelToAssignees ? labelToAssignees[label.name] : []; | ||
return acc.concat(assignee); | ||
}, []) | ||
: ['sgowroji', 'satyanandak', 'iancha1992']; | ||
if (assignees.length > 0) { | ||
await github.issues.addAssignees({ | ||
issue_number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
assignees, | ||
}); | ||
} | ||