Skip to content

Commit

Permalink
Auto assign Pull requests (#5258)
Browse files Browse the repository at this point in the history
Auto assign the pull requests based on the attached labels.
  • Loading branch information
sgowroji committed Aug 22, 2023
1 parent d7e465c commit 68310a1
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/pr-assignee.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Auto Assign Based on Labels
on:
pull_request_target:
types: ["opened", "reopened", "ready_for_review"]

jobs:
assign_based_on_labels:
runs-on: ubuntu-latest
permissions:
pull-requests: 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: |
const labelsToAssignees = {
'product: CLion': ['tpasternak'],
'product: IntelliJ': ['mai93'],
'product: GoLand': ['blorente'],
'product: Android Studio': ['mai93']
// Add more label-assignee mappings here
};
const labels = context.payload.pull_request.labels.map(label => label.name);
const assignees = [];
for (const label of labels) {
if (label in labelsToAssignees) {
assignees.push(...labelsToAssignees[label]);
}
}
if (assignees.length > 0) {
const issue_number = context.payload.pull_request.number;
await github.issues.addAssignees({
issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
assignees
});
}

0 comments on commit 68310a1

Please sign in to comment.