Skip to content

Commit 02bd5e3

Browse files
GITHUB/WORKFLOWS: Add workflow for auto-assigning reviewers based on git blame
1 parent c4acc6c commit 02bd5e3

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Auto-Assign Reviewers
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
jobs:
8+
auto-assign:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Fetch base branch
17+
run: |
18+
git fetch origin ${{ github.event.pull_request.base.ref }}
19+
20+
- name: Run git blame analysis
21+
run: |
22+
# Calculate the diff between the base branch and the current commit
23+
git diff origin/${{ github.event.pull_request.base.ref }} --name-only | while read file; do
24+
echo "Analyzing $file"
25+
git blame -e $file || echo "Error analyzing $file"
26+
done > reviewers.txt
27+
28+
- name: Print reviewers list
29+
run: cat reviewers.txt
30+
31+
- name: Create pull request for changes
32+
uses: peter-evans/create-pull-request@v5
33+
with:
34+
token: ${{ secrets.GITHUB_TOKEN }}
35+
base: ${{ github.event.pull_request.base.ref }}
36+
branch: create-pull-request/patch
37+
commit-message: "[create-pull-request] Automated change"
38+
title: Changes by create-pull-request action
39+
body: |
40+
Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

0 commit comments

Comments
 (0)