diff --git a/.github/workflows/pr-assignee.yml b/.github/workflows/pr-assignee.yml new file mode 100644 index 00000000000..c79b8347614 --- /dev/null +++ b/.github/workflows/pr-assignee.yml @@ -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 + }); + }