Skip to content

Commit

Permalink
Automatically add assignees to issues based on product labels (#6512)
Browse files Browse the repository at this point in the history
* Automatically add assignee to issues with product labels

* Some clean up

* Assignee changes

---------

Co-authored-by: keertk <keerthanakumar@google.com>
  • Loading branch information
sgowroji and keertk authored Jun 27, 2024
1 parent 3969646 commit 2a69f13
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
4 changes: 0 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: Bug Report
description: File a bug report
labels: ["type: bug", "awaiting-maintainer"]
assignees:
- satyanandak
- sgowroji
- iancha1992
body:
- type: markdown
attributes:
Expand Down
4 changes: 0 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: Feature Request
description: Suggest a new feature
labels: ["type: feature request", "awaiting-maintainer"]
assignees:
- satyanandak
- sgowroji
- iancha1992
body:
- type: markdown
attributes:
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/issue-assignee.yml
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,
});
}

0 comments on commit 2a69f13

Please sign in to comment.