diff --git a/.github/workflows/autoassign-prs.yml b/.github/workflows/autoassign-prs.yml new file mode 100644 index 0000000000..0da954d132 --- /dev/null +++ b/.github/workflows/autoassign-prs.yml @@ -0,0 +1,36 @@ +name: PR autoassignment + +on: + pull_request: + types: [opened] + +jobs: + assign-new-issue: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/github-script@v6 + with: + script: | + const externalPrTriager = "kanej"; + + // Within the Github API PRs are issue objects + const pr = await github.rest.issues.get({ + owner: context.issue.owner, + repo: context.issue.repo, + issue_number: context.issue.number + }); + + const isCollaborator = ["OWNER", "MEMBER", "COLLABORATOR"].includes(pr.data.author_association) + + if (isCollaborator) { + return + } + + await github.rest.issues.addAssignees({ + owner: context.issue.owner, + repo: context.issue.repo, + issue_number: context.issue.number, + assignees: [externalPrTriager], + });