File tree 1 file changed +46
-0
lines changed
1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Mark Duplicate PRs
2
+
3
+ on :
4
+ pull_request :
5
+ types : [closed]
6
+
7
+ jobs :
8
+ check_duplicate_prs :
9
+ runs-on : ubuntu-latest
10
+ if : github.event.pull_request.merged == 'true' && github.event.pull_request.user.login == 'dependabot[bot]'
11
+ steps :
12
+ - name : Checkout Repository
13
+ uses : actions/checkout@v4
14
+
15
+ - name : Extract Dependency Name from PR Title
16
+ id : extract
17
+ run : |
18
+ PR_TITLE="${{ github.event.pull_request.title }}"
19
+ DEPENDENCY_NAME=$(echo "$PR_TITLE" | awk -F ' from ' '{print $1}')
20
+ echo "dependency_name=$DEPENDENCY_NAME" >> $GITHUB_OUTPUT
21
+
22
+ - name : Find PRs
23
+ id : find_duplicates
24
+ env :
25
+ DEPENDENCY_NAME : ${{ steps.extract.outputs.dependency_name }}
26
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
27
+ run : |
28
+ PRS=$(gh pr list --search "milestone:${{ github.event.pull_request.milestone.title }} is:merged $DEPENDENCY_NAME" --json number --jq 'map(.number) | join(",")')
29
+ echo "prs=$PRS" >> $GITHUB_OUTPUT
30
+
31
+ - name : Label Duplicate PRs
32
+ if : steps.find_duplicates.outputs.prs != ''
33
+ env :
34
+ PRS : ${{ steps.find_duplicates.outputs.prs }}
35
+ CURRENT_PR_NUMBER : ${{ github.event.pull_request.number }}
36
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
37
+ shell : bash
38
+ run : |
39
+ for i in ${PRS//,/ }
40
+ do
41
+ if [ ! $i -eq "$CURRENT_PR_NUMBER" ]; then
42
+ echo "Marking PR $i as duplicate"
43
+ gh pr edit "$i" --add-label "status: duplicate"
44
+ gh pr comment "$i" --body "Duplicate of #$CURRENT_PR_NUMBER"
45
+ fi
46
+ done
You can’t perform that action at this time.
0 commit comments