-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto assign the pull requests based on the attached labels.
- Loading branch information
Showing
1 changed file
with
45 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,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 | ||
}); | ||
} |