Skip to content

Commit 87fd5d5

Browse files
Merge pull request #145 from neeru24/patch-6
Create assign-pr-author-on-merge.yml
2 parents bd39a3e + 3e6314b commit 87fd5d5

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Assign PR author on merge
2+
3+
on:
4+
pull_request_target:
5+
types: [closed]
6+
7+
permissions:
8+
pull-requests: write
9+
10+
jobs:
11+
assign-author:
12+
runs-on: ubuntu-latest
13+
if: github.event.pull_request.merged == true
14+
15+
steps:
16+
- name: Assign PR to its author
17+
uses: actions/github-script@v7
18+
with:
19+
script: |
20+
const pr = context.payload.pull_request;
21+
22+
// Get the PR author's username
23+
const author = pr.user.login;
24+
25+
// Assign PR to the author
26+
await github.rest.issues.addAssignees({
27+
owner: context.repo.owner,
28+
repo: context.repo.repo,
29+
issue_number: pr.number,
30+
assignees: [author],
31+
});
32+
33+
console.log(`PR #${pr.number} assigned to @${author}`);

0 commit comments

Comments
 (0)