Create assign-pr-author-on-merge.yml #1
Workflow file for this run
This file contains hidden or 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
| name: Assign PR author on merge | |
| on: | |
| pull_request_target: | |
| types: [closed] | |
| permissions: | |
| pull-requests: write | |
| jobs: | |
| assign-author: | |
| runs-on: ubuntu-latest | |
| if: github.event.pull_request.merged == true | |
| steps: | |
| - name: Assign PR to its author | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const pr = context.payload.pull_request; | |
| // Get the PR author's username | |
| const author = pr.user.login; | |
| // Assign PR to the author | |
| await github.rest.issues.addAssignees({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: pr.number, | |
| assignees: [author], | |
| }); | |
| console.log(`PR #${pr.number} assigned to @${author}`); |