diff --git a/.github/workflows/auto-assign-pr.yml b/.github/workflows/auto-assign-pr.yml new file mode 100644 index 00000000000..5ee03c281c9 --- /dev/null +++ b/.github/workflows/auto-assign-pr.yml @@ -0,0 +1,49 @@ +name: Auto-assign PR to Technical Writers + +on: + pull_request: + types: [opened] + +jobs: + auto-assign: + runs-on: ubuntu-latest + permissions: + pull-requests: write + + steps: + - name: Assign PR to creator if on Technical Writers team + uses: actions/github-script@v7 + with: + script: | + const creator = context.payload.pull_request.user.login; + const prNumber = context.payload.pull_request.number; + const assignees = context.payload.pull_request.assignees; + + console.log(`Processing PR #${prNumber} by ${creator}`); + console.log(`Current assignees: ${assignees.length > 0 ? assignees.map(a => a.login).join(', ') : 'none'}`); + + if (assignees.length > 0) { + console.log('PR already has assignees, skipping auto-assignment'); + return; + } + + try { + console.log(`Checking if ${creator} is on technical-writers team...`); + await github.rest.teams.getMembershipForUserInOrg({ + org: context.repo.owner, + team_slug: 'technical-writers', + username: creator + }); + + console.log(`${creator} is on technical-writers team, assigning PR...`); + await github.rest.issues.addAssignees({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + assignees: [creator] + }); + console.log(`Successfully assigned PR #${prNumber} to ${creator}`); + } catch (error) { + console.log(`${creator} is not on technical-writers team, skipping assignment`); + console.log(`Error details: ${error.message}`); + }